Goto deprecated in 3.8

Post Reply
User avatar
CrashN8
Site Admin
Site Admin
Posts: 394
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: 394
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: 394
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: 175
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: 394
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.

Post Reply