Hello Guest it is April 25, 2024, 10:10:17 AM

Author Topic: If then else=need help  (Read 3335 times)

0 Members and 1 Guest are viewing this topic.

If then else=need help
« 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

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: If then else=need help
« Reply #1 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
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: If then else=need help
« Reply #2 on: October 01, 2008, 08:22:04 PM »
That did it!!!!
Thanks I sure have alot to learn.