1 becomes 0!?!?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mrh32
Newbie
Posts: 13
Joined: Thu Feb 20, 2003 3:06 pm

1 becomes 0!?!?

Post by mrh32 » Thu Feb 20, 2003 3:25 pm

Hi, I've been working with your program for a few weeks now and have thoroughly enjoyed doing so. Recently though I have noticed a few odd things, the oddest of which occurred today. I have a fairly long script (1500 lines or so) and somewhere in the middle of it I make the following calls

let>dwfkn=1
Repeat>dwfkn
let>dwffile_name=dwffile_names_%dwfkn%
Send>%dwffile_name%

This used to work but for some reason today it decided to act all strange and instead of sending %dwffile_name_1% which is a file name I get using your separate command, it sends %dwffile_name_0% which refers to nothing to confirm that dwfkn was being set to 0 I inserted a messagemodal> command which indeed confirmed it. I searched through my file and the only other place I ever use the word 'dwfkn' is at the end of the repeat loop where I say

Let>dwfkn=dwfkn+1
Until>dwfkn,dwffile_names_until

So I don't see how I could be setting it to 0 accidentally. Now while you're pondering how that could happen listen up because it gets weirder. If I set dwfkn to 2 or 3, or probably any other number (though those were the only 2 which I tried) it sets them just fine, and does not make them 0.

let>dwfkn=2
Repeat>dwfkn
let>dwffile_name=dwffile_names_%dwfkn%

After realizing this I tried the following workaround

let>dwfkn=3
let>dwfkn=dwfkn-2
Repeat>dwfkn
let>dwffile_name=dwffile_names_%dwfkn%

and amazingly it worked and actually resulted in dwfkn being equal to 1 and not 0.

My question though is why I should even have to do this? Maybe repeat> does something to dwfkn, I'm not sure. Any advice would be appreciated because this workaround is just grating on my sense of logic, so I figured I should ask and see if someone out there might have an idea.

--Matt

mrh32
Newbie
Posts: 13
Joined: Thu Feb 20, 2003 3:06 pm

one more thing

Post by mrh32 » Thu Feb 20, 2003 4:04 pm

You know that thing I said about 3-2=1 being a satisfactory work around, well forget it, it's not. If I do that it just has dwfkn constantly set to 1, if I do let>dwfkn=2 it just has it constantly set to 2, but if I do let>dwfkn=1 it just has it constantly set to 0. Here's another odd thing, this behaviour only occurs when I run my code and not if I step through it. To do one last test I put the following lines in my code

let>dwfkn=1
messageModal>%dwfkn%

The message is 0! There is stuff before these lines and stuff after them, but I don't see how that can matter when I EXPLICITLY set the variable to one and then on the next line of code print it out. Unless your software has some sort of crazy Threading capability which is completely undocumented I have no idea what is going on. Also to ensure that it was not my naming convention I changed the lines to read

let>bolkjljljglkj=1
messageModal>%bolkjljljglkj%

And I still get 0! Obviously when I run this outside of my code in it's own little test script it returns 1, but if you could give me some explanation of how something could have its value changed between the line it is assigned and then absolute next line, and how to correct this I would appreciate it.

--Matt

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Feb 20, 2003 4:05 pm

Hi,

I bet you are setting a variable to zero someplace? And I bet that variable resolves to the value 1. And if you are using % symbols in the wrong place you will therefore get 1=0. I'd imagine it is something like that.

The answer is to USE THE DEBUGGER. That is what it is there for! :wink: Switch on the watch list and step through the script and watch the values being set. You will find the problem.

Also, email [email protected] with your script and I'm quite sure they will spot the error quite quickly and be able to comment on naming and referencing your variables more robustly.
MJT Net Support
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Feb 20, 2003 4:12 pm

Hmm I posted my reply before I saw your second post. Having seen your second post I am completely flumoxed. I can't understand that.

Please send me your script so that I can see what on earth is going on. I refuse to accept that there isn't a logical explanation! Please send me the script file to [email protected]
MJT Net Support
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Feb 20, 2003 4:26 pm

Hello again,

Just a comment on the bit about it acting differently when you step through the code as opposed to running it. Did you step through from the start? If you step through from the first line you will get the same results. If you stepped through from somewhere else and get different results then that suggests the problem is related to my comments in my first post. You want to step through from the beginning to locate the cause of the problem. But feel free to send us the script in any case.
MJT Net Support
[email protected]

mrh32
Newbie
Posts: 13
Joined: Thu Feb 20, 2003 3:06 pm

Thanks

Post by mrh32 » Thu Feb 20, 2003 5:50 pm

I'd like to thank Support for helping to solve my problem. The solution was simple, I had accidentally set 1 to equal 0 by using the line

writeln>c:\AutoTest\MacroData\smokeResult.txt,1,Passes
(I had copied the argument list from the corresponding readln> statement but forgot to remove the line number 1 from the argument list)

This returned 0, because it was successful, and thus set its second parameter '1' to 0. Thus everywhere else in my code where I tried to use 1, it would interpret it as the variable '1' and insert the value I had set it to (0) instead. Thanks a lot guys your help is greatly appreciated.

--Matt

P.S. Stepping through the code from the very start might have solved my problem, but since I didn't realize that you could redefine numbers I don't know if I would have noticed the error.

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