Goto deprecated in 3.8

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Goto deprecated in 3.8

Post by CrashN8 » Thu Jan 04, 2018 12:41 pm

Starting in version 3.8 we will no longer support Goto Statements with VB Scripts. In the case that Goto is simply used to abort program (skip to End) there is a very easy migration to replace Goto Statements with Exit Do.

Here is an example of Program using Goto Statement to skip to End of Program:

Code: Select all

ProgEnd = MsgBox("Do you want to exit program?", 4)
If ProgEnd = 6 Then
  Goto MyEnd
End If
Some Program Steps... Measure, Align, Report, etc.

Code: Select all

MyEnd:
Now, here is the modified Program that will work in version(s) 3.8 and later:
- Notice the Goto Statement and MyEnd: label are commented out, you could simply delete these lines

Code: Select all

Do
ProgEnd = MsgBox("Do you want to exit program?", 4)
If ProgEnd = 6 Then
  'Goto MyEnd
  Exit Do
End If
Some Program Steps... Measure, Align, Report, etc.

Code: Select all

'MyEnd:
ProgExit = 1
Loop Until ProgExit = 1
You do not have the required permissions to view the files attached to this post.

KBeckman
New User
New User
Posts: 2
Joined: Fri Sep 30, 2016 9:05 pm

Re: Goto deprecated in 3.8

Post by KBeckman » Fri May 03, 2019 4:17 pm

What about skipping to specific features? Or is this no longer possible with 3.8?

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Goto deprecated in 3.8

Post by CrashN8 » Fri May 03, 2019 5:49 pm

Skipping Feature can be done several ways without use of GoTo...

If Then Else End if --- Do Until Loop --- etc.

I think you find several examples if you browse the VB Sections of Forum

KBeckman
New User
New User
Posts: 2
Joined: Fri Sep 30, 2016 9:05 pm

Re: Goto deprecated in 3.8

Post by KBeckman » Fri May 03, 2019 6:49 pm

I just now realized just how dumb of a question I just asked. I was already using if then statements to determine which feature to Goto.

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Goto deprecated in 3.8

Post by CrashN8 » Mon May 06, 2019 9:24 am

LOL - no problem... Welcome to the forum.

jswope
Super User
Super User
Posts: 187
Joined: Fri May 17, 2013 12:50 pm

Re: Goto deprecated in 3.8

Post by jswope » Wed Sep 11, 2019 10:44 am

I have a form that I use to fill in data for the report. If they hit cancel then I have the exit do and it ends the program. The problem I have is that it still putts out the saved reports. Is there a way to have it exit without saving the reports?

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Goto deprecated in 3.8

Post by CrashN8 » Thu Oct 03, 2019 10:53 am

I forgot to post answer here after emailing jswope his answer...

You can add a simple VB Script after each Report Operation to evaluate it's OOT and then abort program execution by raising error if the report item is Out of Tolerance. Like this:

Code: Select all

IsOOT = GetReportInfo("Dim_1", "USER_DEF", 6)

If IsOOT <> 0 Then
Error.Raise "Program Aborted - Critical Dimension Out of Tolerance"
End If
This will result in an Error Message as shown below, the program execution stops immediately and the Report is not output.

Aborted_Program.jpg

You do not have the required permissions to view the files attached to this post.

ken60
Power User
Power User
Posts: 98
Joined: Fri Mar 21, 2014 12:32 pm

Re: Goto deprecated in 3.8

Post by ken60 » Wed Mar 04, 2020 1:20 pm

This decision by Nikon is a bad idea for end users as I see now, we have more than 500 programs with "Goto" statement embedded in it, to update all will take quite some time and as you see on 1 of my post Goto function work best in what we try do achieve. "If" "then" "else" or "Do" loop has their own way to function but they can't be cross (jump in and out) like "Goto". Hopefully Nikon will add "Goto" back as an option or so.

Right now, I am trying to figure out how get this program run in "Batch Mode"
Capture.JPG
Line 004

Code: Select all

Do
ProgEnd = MsgBox("Is program Rev. up to date?  Rev.   LWG  Rev. NEW", 4)
If ProgEnd = 7 Then
  Exit Do
End If
Line 029

Code: Select all

ProgExit = 1
Loop Until ProgExit = 1
When select "Yes" the above setup run thru on initial run then pop up "Script syntax check detected an error" at end of program. Select "No" will have same error message

If I move "Do" as shown
Capture1.JPG
"Batch run" will loop from line 009 to line 029 but repeat measure 1st part
You do not have the required permissions to view the files attached to this post.

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Goto deprecated in 3.8

Post by CrashN8 » Wed Mar 04, 2020 2:05 pm

This was no decision we made as no modern VBScript engine allows for GoTo... Starting in version 3.8 we switched from old Cypress Enable Scripting Engine to Microsoft Active Scripting Engine. This was our only option as Cypress Enable does not have 64bit product available. So starting in version 3.8 our VB Scripting engine is very slightly different in terms of supported VB commands.

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Goto deprecated in 3.8

Post by CrashN8 » Tue Mar 10, 2020 10:22 am

After several communications with ken60 I have answer... Thanks Ken for emailing me this Flowchart that explains what you're trying to do.

ken_flow.png


I've attached sample program, see details for VBScript I used here:

Code: Select all

align = MsgBox("Is manual alignment required?", 4)
rev = 6
If align = 6 Then
rev = MsgBox("Is Program Rev up to date?", 4)
End If
Note - If using Batch Run... Create the VB Script above and below this comment in 2 separate Program steps. Then set the VB Script immediately below and the starting point for Looped operations in Batch Run.

Code: Select all

If rev <> 7 Then
If align = 6 Then
  • Manual Alignment Program Steps here...

Code: Select all

End If
  • DCC Alignment and Main Program Here...
Below is optional and only needed if using Batch Run. With this code the entire Batch will terminate when No is pressed for Program Rev prompt.

Code: Select all

Else
Error.Raise "Program Aborted - Program Rev not up to date"
Below is required in all cases...

Code: Select all

End If
You do not have the required permissions to view the files attached to this post.

Post Reply