Input box and Plugging a variable into cli_Execute

Des80

Member
I was wondering how one made an input box to plug the text entered into a variable along with how to then plug the variable into cli_Execute.
 

Des80

Member
Well I have seen some scripts where you could plug in numbers and it placed those in a variable but Couldn't really find it in the coding when I looked ( the Eatdrink script does this ) so I thought that there might be one for strings as well.. Well darn that defeats what I was going to do then. Thank you.
 

lostcalpolydude

Developer
Staff member
The main() function can have parameters that trigger prompts when the script is first run, and those variables can be used for anything at that point.
 

Theraze

Active member
Yep. Use main for that. Something like:

main(int someNumber, string someText, boolean someChoice) {
if (someChoice) count(someNumber);
print(someText);
}
 

Theraze

Active member
If you tried to directly run my example code, it would fail because count isn't a real function. Unless it is in your code, but it wasn't a defined function in this code or an internal function as found in ashref that's valid for an int. This code should be fully executable as an example.
Code:
main(booealn doAnything, int howManyTimes, string showWhat) {
  if (doAnything) {
    if (howManyTimes > 0) for it from 1 to howManyTimes print("Iteration "+it+": "+showWhat);
    else print("You told me to show the text 0 times.");
  }
  else print("You told me not to run the code.");
}
 

Des80

Member
Nah I was trying to run and print through that trying to get the input prompt.. Thank you Theraze.

Ok here is what i kept getting when I tried doing the other as well
Unknown variable 'boolean' (test.ash, line 1)
 
Last edited:

Theraze

Active member
Sounds like you either didn't define it or double-defined. Something like:
main(boolean)
or
main(boolean boolean someChoice)
 

Des80

Member
I copied and pasted what you typed and only changed the mispelling you had on boolean other then that I didn't change anything else.
 
Top