Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-20-2019, 02:25 PM
never2spicy never2spicy is offline
Registered User
 
Join Date: Dec 2019
Posts: 16
Last one for today: Why is my script processing out of order?

Heres my script. I want it to do the yes no prompt first and have the ability to exit. However it runs the crt.Screen.Send and msgbox that the script ran then prompts me for yes or no. How do i get them to process in the right order?

Sub Main
If Not Continue("This script is for doing some validation commands but also saving the config. Do you wish to continue?", "Continue?") Then Exit Sub
If Not Continue("Warning this will also save the config, do you wish to continue?", _
"This save is non-reversible!") Then Exit Sub
MsgBox "Proceeding with execution."
End Sub
Function Continue(strMsg, strTitle)
nButtons = vbYesNo + vbDefaultButton2
nIcon = vbQuestion
If MsgBox(strMsg, nButtons + nIcon, strTitle) <> vbYes Then
Continue = False
Else
Continue = True
End If
End Function
crt.Screen.Send "copy run start"
crt.Screen.Send chr(13)
MsgBox "Script complete. Please see the \\Server\Network Share Root\Logs directory for the log."
Reply With Quote
  #2  
Old 12-20-2019, 03:02 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,104
Hi never2spicy,

I think if you have code outside your Subs and Functions, then you would have to explicitly call Main().

Instead, you could just put the other code inside Main():

Code:
Sub Main  
    If Not Continue("This script is for doing some validation commands but also saving the config. Do you wish to continue?", "Continue?") Then Exit Sub
    If Not Continue("Warning this will also save the config, do you wish to continue?", _
"This save is non-reversible!") Then Exit Sub       
    MsgBox "Proceeding with execution."
    crt.Screen.Send "copy run start" & chr(13)
    MsgBox "Script complete. Please see the \\Server\Network Share Root\Logs directory for the log."
End Sub

Function Continue(strMsg, strTitle)
     nButtons = vbYesNo + vbDefaultButton2   
	nIcon = vbQuestion
     If MsgBox(strMsg, nButtons + nIcon, strTitle) <> vbYes Then
         Continue = False
     Else
         Continue = True
     End If
End Function
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:06 PM.