I hate magic numbers in my code, so I want to replace the numeric literals in my wait commands with constant variable names.
For example:
wait 60 //How it is now
wait MAX_HALT_TIME //How I would like it to be
However, I get the following syntax error when I do this:
FAILURE STInvalidParameters Command wait was called with invalid parameters
Is passing the wait function an integer variable even possible in Eggplant? My declaration of MAX_HALT_TIME
is correct, to my knowledge so there should be no reason why Eggplant can't treat MAX_HALT_TIME
as 60 seconds.
put 3 into Universal MAX_HALT_TIME
Apparently Eggplant does not evaluate global or universal variables until they are called. So the wait command automatically saw the variable being passed to the function as a variable and not the numeric literal that it has been equated to.
My solution to this was to have it evaluate to a numeric literal before I passed it to the wait command. I did this by seperating how I declared my variable (made into two lines instead of one).
put 3 into universal MAX_HALT_TIME //Before
universal MAX_HALT_TIME //After
put 3 into MAX_HALT_TIME //After