VBscript IF statement issues
john geddes from Australia  [6 posts]
12 year
Background on me, i do a bit of C and C++ programming, and am trying to use the VB script plugin.
The 'IF' statement seems to playing havoc on me, because i can't seem to find the right syntax for a comparison.
I have this code:

RBdY = (RY-BY)
RBdX = (RX-BX)
    heading1 = 0
    heading1 = (tan(RBdY/RBdX))*(180/3.14156932)
end if
SetVariable "Heading", heading1

RY, BY, RX, BX are all pixel co-ordinates i have determined before the VB script, and are read in via 'RX = GetVariable("RedX")' etc...
Im trying to detect if RBdX is equal to 0, so i can avoid a division by zero. however the if statement always fails and i'll get a division by 0 error when RBdX is 0.
I've tried '==', also tried '!=' or '<>' and reversed the logic, nothing works.

I can't seem to locate any debugging tools in the built in VBscript plugin, am i just being blind?
Also, is there no function for Pi?

I appreciate any help given on this problem.

Anonymous 12 year
Hi Botagar

Firstly if your more familiar with C programing you may wan to try cscript rather than vbscript http://www.roborealm.com/help/CScript_Program.php

Then if the program is exactly what your using then try adding some spaces to your code instead of



if RBdX=0 then

Take a look at w3schools they have a lot of good examples http://www.w3schools.com/vbscript/vbscript_conditionals.asp

Lastly microsoft did not give us any debugging tools for vbscript so I am afraid you have to go old school and use response.write onto the screen in order to get some understanding on what is going on.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index