I keep getting errors in these 2 lines.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
fightcancer
Macro Veteran
Posts: 260
Joined: Fri Apr 15, 2005 8:32 am

I keep getting errors in these 2 lines.

Post by fightcancer » Sat Oct 11, 2008 1:32 pm

Here's the code in question, line 269, as well as the preceding line and succeeding 2.

Code: Select all

268 Let>StaminaMultiplier=MaxStamina-2
269 Let>StaminaReminder={%intStaminaRegenTime%+(118*%StaminaMultiplier%)-(%kIdleTimeGetHealth%*2)}
270 Message>StaminaReminder
271 GoSub>FocusApp

The error messages I'm getting in MS 10.1.21e are:

ERROR 1:
Macro Scheduler

Line: 269 Operator opMinus incompatible with String

[OK]

ERROR 2:
Macro Scheduler

Line: 269 Internal parser error. Code 10

[OK]
These messages appear back to back, and I think they're always the same. They probably happen less than 1% of the time.

Also, the message box was all gray w/zero characters indicating that the var StaminaReminder was null, empty or just spaces.

Thanks!

EDIT: Fixed the OP code.
Last edited by fightcancer on Sat Oct 11, 2008 3:08 pm, edited 1 time in total.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Oct 11, 2008 2:45 pm

A quick observation would seem to indicate an extra/missing ")" character. You have two "(" chars and only have one ")". Not able to tell the correct location. Can you explain the formula in simpler terms to help ID where the "(...)" chars should be?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Oct 11, 2008 3:08 pm

Hi,

1) As Bob says there's a ")" char missing

2) This error would occur if one of the following conditions existed:

i) MaxStamina was not a numeric - but a string value
ii) kIdleTimeGetHealth was not a numeric - but a string value

One of those values is not being set to a numeric before line 269. They're either not being set at all or are being set to a string value. So it ends up trying to subtract a string, which clearly isn't possible.

You need to find out when and why. Enable logging, use _DUMP_VARS and/or Debug Step to find out. Use the variable explorer to find all lines that create these variables.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

fightcancer
Macro Veteran
Posts: 260
Joined: Fri Apr 15, 2005 8:32 am

Post by fightcancer » Sat Oct 11, 2008 3:11 pm

Oops, that was a transcription error. I was fiddling the spaces trying to get all the characters to display on one line. I just checked the code and that's how it is in my macro.

It usually works, but sometimes gens those errors. Now I'm testing it like this:

Let>StaminaReminder={%intStaminaRegenTime%+(118*%StaminaMultiplier%)}

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Oct 11, 2008 3:18 pm

So sometimes one of those values is set to a string and other times a numeric. You need to trace back and see when those values are set/modified. Some input data or condition is creating a string not a number.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

fightcancer
Macro Veteran
Posts: 260
Joined: Fri Apr 15, 2005 8:32 am

Post by fightcancer » Sat Oct 11, 2008 3:23 pm

mtettmar wrote:1) As Bob says there's a ")" char missing
Yep, that was my clerical mistake.
mtettmar wrote:2) This error would occur if one of the following conditions existed:

i) MaxStamina was not a numeric - but a string value
That's probably the issue since I pull that var using MidStr. Can I convert it to a numeric with this line?

MaxStamina=MaxStamina+0

or

intMaxStamina=MaxStamina+0

Thank you both for the prompt help!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Oct 11, 2008 3:56 pm

Doesn't matter whether you use MidStr or not - the issue is whether or not its VALUE is numeric. The error you are getting is because its value is not numeric - not a valid representation of a number.

Its not how you create it or what function you use it is what value it gets set to.

On the occasions you get this error one of those values is not being set to a value that represents a number. I.e. It contains a character other than those in the range 0-9 or period (".")

Debug. Output those vars to the log file and I guarantee they are not valid numerics. Perhaps due to some dodgy assumptions based on the format of the input data you're performing MidStr on, even if just an edge case.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Oct 11, 2008 4:43 pm

It's sometimes helpful to initialize all of your numeric variables at the beginning of the script.

Let>MaxStamina=0
Let>StaminaReminder=0
Let>intStaminaRegenTime=0
Let>StaminaMultiplier=0
Let>kIdleTimeGetHealth=0
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

fightcancer
Macro Veteran
Posts: 260
Joined: Fri Apr 15, 2005 8:32 am

Post by fightcancer » Sat Oct 11, 2008 5:45 pm

I'm sure you're both right. Is there an easy way to output vars to a log file? I'm not sure how to use debug to trap this error since it so very rarely appears. Thanks again for the help.

(I use a SRT to initialize dozens of vars.)

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Oct 11, 2008 6:42 pm

Two ways to see your variables:

1. Single step through the pgogram, and have the Watch List visible. This will show the value of each variable after the line has been executed.

2. In the file properties, you can set the options to create a log file. But to see the values of the variables, you will need to have the "%" symbol around the variables in your script or else you will only see the names. You could guess about some variables based on response to IF commands. But if you use the "%" symbols you will see the values in the command lines as they are called up. From your small sample it looks like most of your statements will be OK in the log file.

I usually choose the first option for the log file to "Log entry after running step".
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Oct 11, 2008 7:54 pm

A few other ways. Set _DUMP_VARS to 1 and all variables will be logged to the logfile. While it is set to 1 they will be dumped at EVERY line so you may want to switch it on (1) and off (0) at various points.

Another way: Use WriteLn or TimeStamp to output them to a file (which could be the script's log file)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

fightcancer
Macro Veteran
Posts: 260
Joined: Fri Apr 15, 2005 8:32 am

Post by fightcancer » Sun Oct 12, 2008 12:47 am

Ty vm guys! I will explore the debugging, logging, etc.

EDIT: God the logging is so cool!! It gives me the exact info I need in so many ways.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts