Exit Program - Do Loop question

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

Exit Program - Do Loop question

Post by ken60 » Tue Feb 25, 2020 8:06 pm

Here is another issue when upgraded from 3.7sp2 to 3.9 sp2
3.7 sp2.png
In 3.7sp2 I have couples script to run program without manual setup and to verify the current Rev. on work order
3.9 sp2.png
Because of "GOTO commend" not supporting I updated the script as instructed but keep getting this error massage and can't figure out how to fix it, also the DRO text change to small and blackout in "Show transparent"
You do not have the required permissions to view the files attached to this post.

User avatar
CMM Guru
Moderator
Moderator
Posts: 105
Joined: Thu Feb 24, 2011 7:49 pm

Re: Upgrade to 3.9 sp2

Post by CMM Guru » Wed Feb 26, 2020 9:55 am

To fix DRO text, reboot the computer to allow windows to finish "registering" the font. That *should* fix that. I will take a closer look at your error in a little bit.

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

Re: Upgrade to 3.9 sp2

Post by CrashN8 » Wed Feb 26, 2020 10:27 am

It would be a lot easier to assist if you copied all VBScript as text into Forum Post...

I see the Syntax Checker is complaining about step 011 but for some reason you are showing us step 006.

I think you are trying to terminate program depending on user response from prompt. If so, study my working VBScript below and incorporate it fully into you program:

Code: Select all

Do
  MyPrompt = MsgBox("Exit Program?", 4)
    If MyPrompt = 6 Then
      MsgBox("Program Terminating")
      Exit Do
    End if

'CMM Program Steps to skip go here

  MsgBox("Program Complete")
  ProgExit = 1
Loop Until ProgExit = 1

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

Re: Upgrade to 3.9 sp2

Post by ken60 » Wed Feb 26, 2020 4:36 pm

The first screen is capture from 3.7 sp2 showing what I intend to do with the scripts and work fine in 3.7 sp2
The second screen is capture from 3.9 sp2 showing "goto" replaced by "Do"
Without the script for "Manual alignment" the program with script "verify Rev." work fine but program will stop at line 011 if I have both scripts in the program

User avatar
CMM Guru
Moderator
Moderator
Posts: 105
Joined: Thu Feb 24, 2011 7:49 pm

Re: Upgrade to 3.9 sp2

Post by CMM Guru » Wed Feb 26, 2020 4:52 pm

In order to diagnose, we would need to be able to see the VB from "lines" 6, 7, 11, and 32 since they all fit together to make one large program. We are only seeing the fragment of the total program (which includes line 11) in your picture which shows only line 6.

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

Re: Upgrade to 3.9 sp2

Post by ken60 » Wed Feb 26, 2020 7:36 pm

You mean 5, 6, 11, 32 correct

Code: Select all

Line 005   :            answer = MsgBox("IS MANUAL ALIGNMENT REQUIRED?", 4)
                                IF answer = 6 THEN

Line 006  :              Do
                                answer = MsgBox("Is program Rev. up to date?  Rev.   Sht. 1  Rev. A / ADCN 1", 4)
                                IF answer = 6 THEN
                                elseif answer = 7 THEN
                                MsgBox("Program Need up date")
                                Exit Do
                                End if

Line 011  :             End If

Line 032  :             ProgExit = 1
                               Loop Until ProgExit = 1

User avatar
CMM Guru
Moderator
Moderator
Posts: 105
Joined: Thu Feb 24, 2011 7:49 pm

Re: Upgrade to 3.9 sp2

Post by CMM Guru » Thu Feb 27, 2020 9:36 am

If I'm reading your intent correctly...

IF answer = 6 THEN (in OPO6)
I assume this is a 2nd check of the previous "Is Manual Alignment Required" query? In which case, it is not required.
If it is in response to the "Is program Rev up to date?" query, and IF the answer was 6, the answer can never be 7 since it was already set to 6, so the code would never execute.

I'm assuming...
  • You want to either run, or not run, the manual alignment based on the first response?
  • This is a little less clear - You want to simply prompt to update the program based on the response to question #2? Or you want to ABORT the entire run if they say it is not up to date? You want to only do this prompt if they respond a certain way to the manual alignment prompt? (that's the way this is written).
  • I'm confused about what the intent is with the DO loop? Curious as well if a DO requires an END DO as well as the Exit Do.
If I can understand your intent, I can help you (Easily) clean up the logic here.

Now -- as to the error on line 11. I wouldn't think so (I'll have to test this), but maybe if you do the Exit DO it gets confused since the IF/ELSEIF/END IF are isolated? Which leaves a mismatch with number of IF's and END IF's? Just thinking. Not saying that is so!

I found part of my answer by scrolling down. :-) You do have an abort at the end.

I'll do some testing once I understand the intent of what the 2nd prompt is supposed to do (prompt only or exit the program) and if the 2nd prompt is only supposed to run IF you get a certain response to the first prompt?

User avatar
CMM Guru
Moderator
Moderator
Posts: 105
Joined: Thu Feb 24, 2011 7:49 pm

Re: Upgrade to 3.9 sp2

Post by CMM Guru » Thu Feb 27, 2020 9:51 am

Partial answer for you... Indentation to match begin/end statements shows that the END IF for the first IF is inside a loop. This is going to be a problem at LEAST on the 2nd run, if not before, since when it loops back, it will see an END IF with not matching IF.

Line 005 :

Code: Select all

answer = MsgBox("IS MANUAL ALIGNMENT REQUIRED?", 4)
IF answer = 6 THEN

Line 006 :

Code: Select all

Do
 answer = MsgBox("Is program Rev. up to date?  Rev.   Sht. 1  Rev. A / ADCN 1", 4)
    IF answer = 7 THEN
    MsgBox("Program Need up date")
    Exit Do
  End if
Line 011 :

Code: Select all

End If
Line 032 :

Code: Select all

ProgExit = 1
Loop Until ProgExit = 1

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

Re: Upgrade to 3.9 sp2

Post by ken60 » Thu Feb 27, 2020 10:22 am

Thank you Guru, my intend in this program is when run this program 1st time I will do manual align part (1st query) then program will prompt for checking current rev. (2nd query) if up to date program will continue if not program will jump to end of program, when run program 2nd time It will skip the manual and the verify all together, it will execute the rest of program if I don't want to do manual alignment. This setup works fine in 3.7 sp2 with "goto" statement

User avatar
CMM Guru
Moderator
Moderator
Posts: 105
Joined: Thu Feb 24, 2011 7:49 pm

Re: Upgrade to 3.9 sp2

Post by CMM Guru » Thu Feb 27, 2020 10:27 am

Well... if you don't want it to loop over and over (I can modify this so it loops instead), this is cleaner. IF you loop, do you want the question "is program up to date" every loop?


Code: Select all

answer = MsgBox("Is program Rev. up to date?  Rev.   Sht. 1  Rev. A / ADCN 1", 4)
IF answer = 7 THEN
    MsgBox("Program needs to be updated")
ELSE
    answer = MsgBox("Is manual alignment required?", 4)
    IF answer = 6 THEN
*********************
CMM-Manager OPO lines for manual alignment
*********************

Code: Select all

    END IF

*********************
CMM-Manager OPO lines Inspection
*********************

Code: Select all

END IF

Post Reply