WoW:API SecureCmdOptionParse: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(New page: {{wowapi}} __NOTOC__ Evaluates macro options in the string and returns the appropriate sub-string or nil <!-- List return values and arguments as well as function name, follow Blizzard u...)
 
m (Move page script moved page API SecureCmdOptionParse to API SecureCmdOptionParse without leaving a redirect)
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:


Evaluates macro options in the string and returns the appropriate sub-string or nil
Evaluates macro options in the string and returns the appropriate sub-string or nil
 
  result, target = SecureCmdOptionParse("macroText")
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
  result = SecureCmdOptionParse(cmd)
 


== Arguments ==
== Arguments ==
<!-- List each argument, together with its type -->
;macroText : a string containing the macro conditions to be parsed.
 
:;cmd : String - the string to be parsed
 


== Returns ==
== Returns ==
<!-- List each return value, together with its type -->
;result : The chosen clause text, or no return (nil) if none of the clauses apply.
 
;target : The [target=(unit)] argument of the chosen clause, if such an argument exist.
:;result : String - the selected sub-string or nil
 


== Example ==
== Example ==
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory -->
  print(SecureCmdOptionParse("[mod:alt] Alt is down; Alt is not down")); -- Prints appropriate text
  local result = SecureCmdOptionParse("[mod:alt] Alt is down; Alt is not down")
print(SecureCmdOptionParse("[target=pet] Cast at Pet")); -- Prints 'Cast at Pet', 'pet'
 
  print(SecureCmdOptionParse("[nomod,mod] Alt is not down")); -- Prints nothing (nomod and mod cannot both be true)
<big>'''Result'''</big>
<!-- If it helps, include example results here, though they are not required. You're allowed to cheat liberally since WoW isn't a command line language. -->
 
If the alt key is being held down when the above line is executed then result will be "Alt is down" otherwise it will be "Alt is not down"
 
Commands which don't meet any of the specified conditions will return nil.  For example
 
  local result = SecureCmdOptionParse("[nomod:alt] Alt is not down")
 
Will return nil if the alt key is held down while it's called and will return "Alt is not down" otherwise.


== Details ==
== Details ==
<!-- Details not appropriate for the main description can go here.
This command can be used to implement the same conditional processing that Blizzard's macro system uses.  It is the same API they use and so supports all the same conditionals.
    REMOVE the section if you're just going to restate the intro line! -->
 
: This command can be used to implement the same conditional processing that Blizzard's macro system uses.  It is the same API they use and so supports all the same conditionals.


: Note that item links can not be part of the commands because they contain square brackets [], which get interpreted by the parser as modifiers.
Note that item links can not be part of the commands because they contain square brackets [], which get interpreted by the parser as modifiers.

Latest revision as of 04:47, 15 August 2023

WoW API < SecureCmdOptionParse

Evaluates macro options in the string and returns the appropriate sub-string or nil

result, target = SecureCmdOptionParse("macroText")

Arguments[edit]

macroText
a string containing the macro conditions to be parsed.

Returns[edit]

result
The chosen clause text, or no return (nil) if none of the clauses apply.
target
The [target=(unit)] argument of the chosen clause, if such an argument exist.

Example[edit]

print(SecureCmdOptionParse("[mod:alt] Alt is down; Alt is not down")); -- Prints appropriate text
print(SecureCmdOptionParse("[target=pet] Cast at Pet")); -- Prints 'Cast at Pet', 'pet'
print(SecureCmdOptionParse("[nomod,mod] Alt is not down")); -- Prints nothing (nomod and mod cannot both be true)

Details[edit]

This command can be used to implement the same conditional processing that Blizzard's macro system uses. It is the same API they use and so supports all the same conditionals.

Note that item links can not be part of the commands because they contain square brackets [], which get interpreted by the parser as modifiers.