Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 11:46:28 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  GoTo Statment?
Pages: 1   Go Down
Print
Author Topic: GoTo Statment?  (Read 421 times)
0 Members and 2 Guests are viewing this topic.
Tony Bullard
Active Member

Offline Offline

Posts: 83


View Profile
« on: June 27, 2011, 07:42:23 AM »

I’m trying to set up a branching statement in a Macropump. I’m testing the following code in the VB Script Editor. I get this error message when executed: “Error on line 7- Label not defined” If I put the Label before the GoTo statement it will branch.

Dim torch As String
torch = isoutputactive(output1)
If torch = "true" Then
MsgBox "   Back to manual control "
   
   GoTo test
   
End If
Print torch
test:
Print "Ended"   

The following from VB-Script-commands.pdf.

"Cypress Enable has complete process control functionality.  The
control structures available are Do loops, While loops, For loops,
Select Case, If Then , and If Then Else.  In addition, Cypress Enable
has one branching statement:  GoTo. The Goto Statement branches to
the label specified in the Goto Statement.
 
Goto label1
  .
  .
  .
 
label1:
 
The program execution jumps to the part of the program that begins
with the label "Label1:". "

Also is using Subs good practice in a Macropump.
I would appreciate a copy on someone’s macropump code that has Lables and Subs in it.
Thanks for any help in advance.
Tony

Logged
djc
Active Member

Offline Offline

Posts: 47


View Profile
« Reply #1 on: June 27, 2011, 03:15:43 PM »

I’m trying to set up a branching statement in a Macropump.

Doesn't answer your question, but you can use an ELSE with the IF to remove the need for GOTO. Similarly, SELECT, CASE could be used.

I can't be bothered to look at the Enable documents just now, but wonder if you need a number in the label name (label1 rather than just label)?

OK, now been bothered. Have a look at p.85, the GOTO statement: "Branches unconditionally and without return to a specified label in a procedure." I read that as meaning it is necessary to have the GOTO and the label between your SUB and END SUB statements.
 
« Last Edit: June 27, 2011, 03:27:32 PM by djc » Logged
Atlas56
Active Member

Offline Offline

Posts: 14


View Profile
« Reply #2 on: June 27, 2011, 09:02:19 PM »

Try this code, do you see what you were missing. The VB-Script-Commands.pdf manual or edit the Mach3 wizard code to see subroutines.

Sub test99()
   Dim torch As String
   torch = isoutputactive(output1)
   If torch = "true" Then
      MsgBox "   Back to manual control "
      GoTo test
   End If
   Print torch
   test:
   Print "Ended"   
End Sub
Logged
Tony Bullard
Active Member

Offline Offline

Posts: 83


View Profile
« Reply #3 on: June 28, 2011, 06:38:20 AM »

Thanks for all of your help. You are right, the GoTo statement has to be in a Sub or procedure. I guess what through me was that on page 9 it reads “The program execution jumps to the part of the program that begins with the label "Label1:". “

From VBEnduser.pdf
“Branches unconditionally and without return to a specified label in a
procedure. “

From VB-Script-Commands.pdf on  page 9
“The program execution jumps to the part of the program that begins
with the label "Label1:". “

From VB-Script-Commands.pdf on  page 84
Branches unconditionally and without return to a specified label in a
procedure.

One says Program, one says procedure.
Tony
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!