msgbox question

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
ainterne
Junior Coder
Posts: 29
Joined: Tue Jun 05, 2007 4:03 am

msgbox question

Post by ainterne » Thu Apr 02, 2009 8:00 pm

Hi, does anyone now how to set a timer on a msgbox please?

I need to just return the info on screen I want to display, wait 3 seconds and then the script continue.

Code: Select all

Function FTPRESTORE(some_command,prompt,shost,slogin,spasswd,sServer,Appliance)
    On Error Resume Next
    s = ssh.Execute("ftp " & sServer & vbLF, "):")
    s = ssh.Execute( "xxxxx" & vbLF,":")
    s = ssh.Execute( "xxxx" & vbLF, "ftp>")
    s = ssh.Execute( "lcd /opt/qip/dhcp" & vbLF, "ftp>")
    s = ssh.Execute("get /archive/webdir/system_logs/" & sServer & "/dhcpd.conf/" & " dhcpd.conf_FTPRESTORE" & vbLF,">")
    s = ssh.Execute("get /archive/webdir/system_logs/" & sServer & "/dhcpd.pcy/" & " dhcpd.pcy_FTPRESTORE" & vbLF,">")
    s = ssh.Execute( "lcd /var/named/" & vbLF, "ftp>")
    s = ssh.Execute("quit" & vbLF, "regex:[\$%#>] $")
    s3 = ssh.Execute( "restart_service ALL" & vblf, "regex:[\$%#>] $")
    ' I want the message box here to just display the return txt for 3
 seconds.
    msgbox s3
    msgbox "Trasfer complete and services restarted. Please check QIP service in the Grid and that lights are greeen."
END Function
[/code]

Thanks, Phil.
Phil.......

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Apr 02, 2009 10:08 pm

I don't know if there is a way, I'd be tempted to use a Macro Scheduler dialog.

Code: Select all

VBSTART
Function FTPRESTORE(some_command,prompt,shost,slogin,spasswd,sServer,Appliance)
    On Error Resume Next
    s = ssh.Execute("ftp " & sServer & vbLF, "):")
    s = ssh.Execute( "xxxxx" & vbLF,":")
    s = ssh.Execute( "xxxx" & vbLF, "ftp>")
    s = ssh.Execute( "lcd /opt/qip/dhcp" & vbLF, "ftp>")
    s = ssh.Execute("get /archive/webdir/system_logs/" & sServer & "/dhcpd.conf/" & " dhcpd.conf_FTPRESTORE" & vbLF,">")
    s = ssh.Execute("get /archive/webdir/system_logs/" & sServer & "/dhcpd.pcy/" & " dhcpd.pcy_FTPRESTORE" & vbLF,">")
    s = ssh.Execute( "lcd /var/named/" & vbLF, "ftp>")
    s = ssh.Execute("quit" & vbLF, "regex:[\$%#>] $")
    s3 = ssh.Execute( "restart_service ALL" & vblf, "regex:[\$%#>] $")
    ' I want the message box here to just display the return txt for 3
 seconds.
   ' msgbox s3
   ' msgbox "Trasfer complete and services restarted. Please check QIP service in the Grid and that lights are greeen."
END Function
VBEND

VBEval>FTPRESTORE(some_command,prompt,shost,slogin,spasswd,sServer,Appliance),result

Dialog>Dialog1
   Caption=
   Width=559
   Height=80
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label=Trasfer complete and services restarted. Please check QIP service in the Grid and that lights are greeen,24,16
EndDialog>Dialog1

Show>dialog1
Wait>3
CloseDialog>dialog1

ainterne
Junior Coder
Posts: 29
Joined: Tue Jun 05, 2007 4:03 am

Post by ainterne » Fri Apr 03, 2009 1:47 am

Thank you,

What I would like to know is if I can update the dialog label from a set of variables with different messages.

e.g

Let>mbx1=some response
Let>mbx2=another response.

In this way set different messages for different steps in the script.
I was just going to feed the variables back into msgbox.

The reason is so that I can feedback the user info based on progress of the script and let them see files that have been converted etc.

Otherwise I think I would have to have a lot of dialogs?

Is it possible to feed variables into the Labels?

Thanks for your reply. Its certainly a gooc solution .

Phil.
Phil.......

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Apr 03, 2009 3:27 am

Here's the dialog portion modified to give a different message in the same dialog every three seconds then quit

Code: Select all

Dialog>Dialog1
   Caption=
   Width=559
   Height=80
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label=Trasfer complete and services restarted. Please check QIP service in the Grid and that lights are greeen,24,16
EndDialog>Dialog1

Show>dialog1
Wait>3
CloseDialog>dialog1
Let>dialog1.mslabel1=This would be the second message
ResetDialogAction>dialog1
Show>dialog1
Wait>3
CloseDialog>dialog1
Let>dialog1.mslabel1=This would be the third message....Etc.
ResetDialogAction>dialog1
Show>dialog1
Wait>3
CloseDialog>dialog1
Let>dialog1.mslabel1=Goodbye...        ;-)
ResetDialogAction>dialog1
Show>dialog1
Wait>3
CloseDialog>dialog1

Exit>0

ainterne
Junior Coder
Posts: 29
Joined: Tue Jun 05, 2007 4:03 am

Post by ainterne » Sat Apr 04, 2009 12:13 am

Hi,

I though I would try your solution and then got carried away:-)
I have added my original template code so you could see how it is supposed to piece together.

I am trying to get the

LibFunc>user32,EnableWindow,lfres,Dialog1.msCheckBox4.HANDLE,1

working, I have it working in simple format but not in this script yet.
I need to have some dialog options off when some options are picked
visa versa.

As you can probably see it bloats the code quite a bit by not being able to have the 'msgbox on in the VB block.

As you can see the VB Block is dummy, normally I have my Weonlydo Active X in there doing the work. I use the Weonlydo Active X dll all the time now and it's very useful.

As you can see here though I just wanted the msgbox events to come up on the screen but not with Yes/No etc options, just a 1 or 2 second show on screen.

Anyway, thank you very much for your help and support, I really do appreciate it.

I would appreciate your thoughts on my efforts and please don't hold back in pointing out my mistakes :-)

Phil.


Code: Select all

VBSTART
Function Connect
'event
'msgbox "Send Username"
'event
'msgbox "Send Password"
'event
'msgbox "Connection OK"
End Function

Function Backup
'event
'msgbox "Saved File_1 as File_1_old"
'event
'msgbox "Saved File_2 as File_2_old"
'event
'msgbox "Saved File_3 as File_3_old"
End Function

Function Transfer
'START TRANSFERING FILES AND DISPLAY EACH TRANSFER
'event
'msgbox "Transfer_file_1 OK!"
'event
'msgbox "Transfer_file_2 OK!"
'event
'msgbox "Transfer_file_3 OK!"
'msgbox "FILES HAVE COMPLETED TRANSFER"
End Function

Function RestartServices
'Once files have completed transfer, HUP process
'event
'msgbox "Restart_Services have completed"
End Function

Function Backout
'Needed if backout is required.
'event
'msgbox "Copied File_1_old back to File_1"
'event
'msgbox "Copied File_2_old back to File_2"
'event
'msgbox "Copied File_3_old back to File_3"
End Function

Function Disconnect
'Disconnect.
'event
'msgbox "Closed session OK!."
End Function

VBend

Dialog>Dialog1
   Caption=Control Events Panel
   Width=391
   Height=385
   Top=220
   Left=501
   Max=1
   Min=1
   Close=1
   Resize=1
   CheckBox=msCheckBox1,Connect to remote server.,96,72,179,True
   CheckBox=msCheckBox3,Transfer Files to remote server.,96,128,218,False
   CheckBox=msCheckBox5,Restart Services on remote server.,96,192,191,False
   CheckBox=msCheckBox6,Diconnect from remote server.,96,224,185,True
   Label=Process options,64,32,true
   CheckBox=msCheckBox4,Backout to original files on remote server.,97,159,192,False
   Button=Go,96,256,75,25,1
   Button=Cancel,208,256,75,25,2
   CheckBox=msCheckBox2,Backup current files before transfer.,98,99,207,True
EndDialog>Dialog1

Dialog>Dialog2
   Caption=Running...
   Width=559
   Height=112
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label=Connection made to server OK!,24,48,true
   ProgressBar=msProgressBar1,28,14,485,17,0
EndDialog>Dialog2


Label>MainLoop
  Show>Dialog1,result
    LibFunc>user32,EnableWindow,lfres,Dialog1.msCheckBox4.HANDLE,1
  If>result=2,End
  If>result=1,Go
Goto>MainLoop

SRT>Go
Let>t1=dialog1.msCheckBox1
Let>t2=dialog1.msCheckBox2
Let>t3=dialog1.msCheckBox3
Let>t4=dialog1.msCheckBox4
Let>t5=dialog1.msCheckBox5
Let>t6=dialog1.msCheckBox6
Let>Dialog2.msprogressbar1=0

If>t1=True
 VBeval>connect,res1
 Show>dialog2
  SetDialogObjectVisible>Dialog1,msLabel1,1
  Let>dialog2.msLabel1=Connecting to server!
    Let>k=0
      Repeat>k
        Let>Dialog2.msprogressbar1=k
        ResetDialogAction>Dialog2
        Wait>0.5
        Let>k=k+100
      Until>k>100
    Let>dialog2.msLabel1=Connected to server OK!
  ResetDialogAction>Dialog2
 Wait>1
 CloseDialog>dialog2
Endif

 If>t1=False
 Let>MSG_HEIGHT=200
 Let>MSG_WIDTH=600
 Let>MSG_CENTERED=1

 Message>You cannot perform anyother actions untill you connect! %CRLF%%CRLF% Goodbye!
 wait>1
 CloseDialog>Message
 
 goto>End
Endif

//SetDialogObjectVisible>
//disable button1
LibFunc>user32,EnableWindow,lfres,Dialog1.msButton1.HANDLE,0

  If>t2=True
  VBeval>backup,res2
  Show>dialog2
  SetDialogObjectVisible>Dialog2,msLabel1,1
  LibFunc>user32,EnableWindow,lfres,Dialog2,msLabel1.HANDLE,0
  Let>dialog2.msLabel1=Backing up config and data to qipupdate.ford.com!
    Let>k=0
      Repeat>k
        Let>Dialog2.msprogressbar1=k
        ResetDialogAction>Dialog2
        Wait>0.5
        Let>k=k+20
      Until>k>100
    Let>dialog2.msLabel1=Backup completed successfully and files amended to new format OK!
  ResetDialogAction>Dialog2
  Wait>2
  CloseDialog>dialog2
  Wait>1
  CloseDialog>dialog2
  ELSE
  Endif

    If>t3=True
    VBeval>Transfer,res3
    Show>dialog2
    SetDialogObjectVisible>Dialog2,msLabel1,1
    Let>dialog2.msLabel1=Transfering files back to new upgraded server!
    Let>k=0
        Repeat>k
          Let>Dialog2.msprogressbar1=k
          ResetDialogAction>Dialog2
          Wait>0.5
          Let>k=k+20
        Until>k>100
    Let>dialog2.msLabel1=Files transfered back OK!
    ResetDialogAction>Dialog2
    Wait>2
    CloseDialog>dialog2
    ELSE
    Endif

    If>t5=True
    VBeval>RestartServices,res5
    Show>dialog2
    SetDialogObjectVisible>Dialog2,msLabel1,1
    Let>dialog2.msLabel1=Restarting services on upgraded server!
    Let>k=0
        Repeat>k
          Let>Dialog2.msprogressbar1=k
          ResetDialogAction>Dialog2
          Wait>0.5
          Let>k=k+15
        Until>k>100
    Let>dialog2.msLabel1=Services started ok and working!
    ResetDialogAction>Dialog2
    Wait>1
    CloseDialog>dialog2
    ELSE
    Endif

  If>t4=True
  VBeval>backout,res4
   Show>dialog2
    Let>dialog2.msLabel1=Backing out config files to stop DNS/DHCP services!
    Let>k=0
        Repeat>k
          Let>Dialog2.msprogressbar1=k
          ResetDialogAction>Dialog2
          Wait>0.5
          Let>k=k+20
        Until>k>100
    Let>dialog2.msLabel1=Services stopped and services not active!
    ResetDialogAction>Dialog2
    Wait>1
    CloseDialog>dialog2
  ELSE
  Endif

If>t6=True
VBeval>disconnect,res6
    Show>dialog2
    SetDialogObjectVisible>Dialog2,msLabel1,1
    Let>dialog2.msLabel1=Disconnecting!
    Let>k=0
        Repeat>k
          Let>Dialog2.msprogressbar1=k
          ResetDialogAction>Dialog2
          Wait>0.5
          Let>k=k+100
        Until>k>100
    Let>dialog2.msLabel1=Disconnected and port closed !
    ResetDialogAction>Dialog2
    Wait>2
    CloseDialog>dialog2
ELSE
Endif

END>

Label>End

Phil.......

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts