Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: dhelfter on October 01, 2008, 05:37:17 PM

Title: If then else=need help
Post by: dhelfter on October 01, 2008, 05:37:17 PM
Hello All. I am new to this vb script stuff. i have managed to write so simple code by following other people on here and learning what I can. I am trying to write a very simple macro. I have put a button on my screen that is label toggle turret. When I click this button it executes my code to turn turret one step(or tool)It worked gret. So I decided to have it also update the tool dro, that even worked great, however I need the dro to set back to 1 when I am at tool 8. So here is the code I wrote:

currenttool=getoemdro(824)
newtool=currenttool + 1

If
currenttool=8 Then
setoemdro(824,1)
Else 
setoemdro(824,newtool)
End If

activatesignal (output2)
code "g04 p.6"
While ismoving()
sleep 50
Wend
deactivatesignal (output2)
code "g04 p.6" 

prior to this I had the same code except no if then statement, only setoemdro(824,newtool) and it worked. So i know I am doing something wrong with the if then, but what?
Thanks
Title: Re: If then else=need help
Post by: ger21 on October 01, 2008, 06:32:52 PM
Try it like this:

If currenttool=8 Then
setoemdro(824,1)
Else
setoemdro(824,newtool)
End If
Title: Re: If then else=need help
Post by: dhelfter on October 01, 2008, 08:22:04 PM
That did it!!!!
Thanks I sure have alot to learn.