When you invoke an ASH script from the gCLI, you can include parameters on the command line:
If myScript1 has the following:
invoking like this:
will parse the command line and coerce the arguments into the expected data types and bind them to the function parameters.
An ASH script's main function can also have a single string parameter which receives all the arguments concatenated
invoked via
or even
will bind argument parameters to "jump 10 feet"
It'd be nice if in the "single string argument" case you could invoke the script with no arguments and it would call the script with an empty string. Instead, ASH considers that "parameters" is required and prompts the user to supply a string.
I have an idea for a backwards-compatible way to deal with this that uses a feature I implemented a few years ago - long after current ASH script invocation was implemented. What if we allowed the final argument of a main() function to be a vararg?
could allow
to bind "command" to "jump" and "parameters" to { "backwards" }
and
binds "command" to "jump" and "parameters" to { "10", "feet" }
and even
binds command to "jump" and "parameters" to {} - without prompting for a "missing" second argument.
You want a script with more freeform command line?
allows
binds "parameters" to {}, {"abc"} and {"abc, "def"} with no user prompting
What about the parentheses-less invocation?
for a main with a single "string" argument gives you a single string, but with a string... argument, it could implicitly split the command line and give you {"abc", "def", xyz"}
I think I would like it to have a fancy split, in which you could use "\ " and "\\" to embed a space or \ in the string. Maybe \s or \n.
I have quite a few scripts which could benefit from this.
Thoughts?
If myScript1 has the following:
Code:
void main(int arg1, string arg2, item arg3)
...
Code:
> call myScript1 (1, abc, shadow venom)
An ASH script's main function can also have a single string parameter which receives all the arguments concatenated
Code:
void main(string parameters)
{
...
}
Code:
call myScript2 (jump, 10, feet)
Code:
call myScript2 jump 10 feet
It'd be nice if in the "single string argument" case you could invoke the script with no arguments and it would call the script with an empty string. Instead, ASH considers that "parameters" is required and prompts the user to supply a string.
I have an idea for a backwards-compatible way to deal with this that uses a feature I implemented a few years ago - long after current ASH script invocation was implemented. What if we allowed the final argument of a main() function to be a vararg?
Code:
void main(string command, string... parameters)
{
}
Code:
call myScript3(jump, backwards)
and
Code:
call myScript3(jump, 10, feet)
and even
Code:
call myScript3(jump)
You want a script with more freeform command line?
Code:
void main(string... parameters)
{
}
Code:
call myScript4
call myScript4 (abc)
call myScript4 (abc, def)
What about the parentheses-less invocation?
Code:
call myScript4 abc def xyz
I think I would like it to have a fancy split, in which you could use "\ " and "\\" to embed a space or \ in the string. Maybe \s or \n.
I have quite a few scripts which could benefit from this.
Thoughts?