VB Timer returns string?? i need integer!

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

VB Timer returns string?? i need integer!

Post by rblack » Thu Aug 05, 2010 6:07 pm

hello,

i am fighting all day with strings and integer, a simple string2int or working CInt(string) funtion would solve the problem, but it doesnt work, so plese help me in another way.

I want to measure the elapsed time, and i do the following operations:

==============
VBSTART
VBEND

VBEval>Timer,opened
label>start
//200 lines of code, but not a single word include "open" or "close", there are no hidden characters

VBEval>Timer,closed

let>diff=closed-opened

if>diff>3000
goto>start
endif

=================

unfortunatelu the diff variable is recognized as STRING, i tried to do

if>{%closed%-%opened%}start
endif

and some parse errors occured, but it worked. Nevertheless i do not want any errors to occur.

I tried to use
VBEval>Timer-%opened%,elapsed

but i got complie errors when using that line

I am using Macro Sheduller 11
PLEASE HELP! I AM REALLY FED UP WITH THIS PROBLEM AND UNPROPER NUMBERS RECOGNITION

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Aug 05, 2010 6:24 pm

Try:

Code: Select all

VBSTART
VBEND

VBEval>Timer,opened
label>start
//200 lines of code, but not a single word include "open" or "close", there are no hidden characters

VBEval>Timer,closed


//Percents around the variables
let>diff=%closed%-%opened%



let>diff=closed-opened

if>diff>3000
goto>start
endif 
a simple string2int or working CInt(string) funtion would solve the problem,
There are no "strings" or "integers" in Macro Scheduler. The individual functions deal with text and decide correctly what the text format might be. There is no requirement nor any method to declare a format.

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Thu Aug 05, 2010 7:30 pm

i have % around the variables, but the forum has removed this

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Thu Aug 05, 2010 7:35 pm

deal with text and decide correctly
then why i keep getting the error:
"Line: 138 Operator opMinus incompatible with String
Line: 138 Internal parser error. Code 10"

and line 138 and 137 are the followin ones:

Code: Select all

//Percents around the variables
let>diff=%closed%-%opened%
if>diff>3000
goto>start
endif 

[/quote]

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Thu Aug 05, 2010 7:44 pm

even
let>IGNOREERRORS=1

dosent handle those 2 bugs from macro sheduller

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

Post by Marcus Tettmar » Fri Aug 06, 2010 8:12 am

I have no problems with your code, copied below.

Code: Select all

VBSTART
VBEND
VBEval>Timer,opened
label>start
//200 lines of code, but not a single word include "open" or "close", there are no hidden characters
VBEval>Timer,closed
let>diff=closed-opened
if>diff>3000
  goto>start
endif
Works fine for me. I'm running Macro Scheduler 12.0.5.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Fri Aug 06, 2010 3:00 pm

Hi rblack,

Make sure you have used Edit>Remove Trailing Spaces to ensure all of your variable names and variable values are what you expect.

Sometimes a contaminated variable value can be fixed as follows:

Code: Select all


//variables intended to be numeric but may contain some extra characteres causing MS to interpret it as a string.

//remove extra characters by forcing a numeric interpretation
Let>opened=%opened%+0
Let>closed=%closed%+0
//Now the calculation should work
Let>diff=%closed%-%open%
I ran your code in debug mode and got these values:

DIFF=3
CLOSED=29340.67578125
OPENED=29337.67578125

For some reason the results are not coming back as integers, but as a decimal number with a very unrealistic precision.

Please check the syntax of the CLOSED and OPENED values returned by the Timer. Do they contain the commas (the THOUSANDS_SEPARATOR). That will cause the error you see.


Your posts of code should not remove the percent signs if you use the Code button and click the Disable HTLM in this post checkbox.

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