I am having some trouble with dialog boxes. The script below calls a proc
"pass_word" which checks the environment settings of a users pc and then
Compares this to entries in an array.
If the check is successful a dialog box is called. No problems up to here.
If a radio button is selected on the dialog box and the OK pushbutton is pressed,
Another dialog box is called.
However one of the edit boxes contains the text of the domain name, which was used in Proc "pass_word". How is this passed from one procedure to another, as the variables are all local? Also if a text is selected from a list box in dialog 3 this is passed to dialog 1 if cancel is selected.
If anyone can help it would be much appreciated,
I have posted a quick test script to explain a bit more.
Apologies for the programming, it's all new to me.
;************************** Global variables *******************************
Integer Choice
Integer Exitflag
proc main
;*********************** Define Local variables for Main Proc ****************
;****************************************************************************
;******************************** Password check **************************
;*** call procedure pass_word *****
;****************************************************************************
pass_word ()
;******************************** Inital Dialogbox *************************
;*** call procedure inital_user_selection () *****
;****************************************************************************
While 1
inital_user_selection () ;Call procedure inital_user_selection ()
;This calls a dialogbox for user selection
dlgdestroy 1 CANCEL ; Destroy the dialog box.
if exitflag == 1 ; If the Quit button from inital_user_selection ()
; is selected, it sets exitflag = 1, exitwhile.
exitwhile
endif
if Choice == 22 ; Evaluate radio group state from inital_user_selection ().
proc1 () ; Call procedure
endif
if Choice == 23 ; Evaluate radio group state from inital_user_selection ().
proc2 () ; Call procedure
endif
endwhile
exit ;exit script
Endproc ;end main proc
;******************************************************************************************************
;****************************** Procdeures *******************************************************
;******************************************************************************************************
Proc pass_word
string compname
string compdomain
integer cnt
integer flag = 1
string pass[2]
pass[0] = "Flynn GavinAU01A"
pass[1] = "Bloggs JoeAU01A"
getenv "username" compname ; Get the variable from env i.e same as using SET at the CMD prompt.
getenv "userdomain" compdomain ; Get username from env and domain name
strcat compname compdomain ; Concatenates the two strings into string companme
breakpoint
while cnt <2 && flag !=0 ; If more users are added increase cnt loop,
;
strcmp compname pass[cnt] flag ; Performs a case-sensitive comparison on the two strings
; flag will be set to 0 if the strings are identical.
cnt=cnt + 1 ; Increment cnt
endwhile
if flag == 0 ; check the staus of flag return to main proc if flag = 0
; i.e password/user is valid
Return
else ; otherwise display message and exit script if flag !=0
; i.e if password/user is not valid
errormsg "You are not Authorised to use this script " Compname
Exit ;exit the script
endif
Endproc
;*************************************************************************************************
;*** Call Inital dialogue Box to allow user to select a Radio button *********
;*** Evaluate the selection and call the relevant procedure *********
;*************************************************************************************************
Proc inital_user_selection
integer Event ; Dialog box event
dialogbox 1 34 19 470 292 27 " Quick test"
radiogroup 1 choice
radiobutton 22 43 32 101 11 "Button1"
radiobutton 23 43 47 120 11 "Button2"
endgroup
pushbutton 20 142 252 40 13 "Ok" OK DEFAULT
pushbutton 21 220 251 40 13 "Quit" CANCEL
enddialog
while 1 ;loop forever
dlgevent 1 Event ; Read dialog event.
switch Event ; Evaluate dialog event.
case 0 ; No event do nothing
endcase
case 21 ; Cancel selected
Exitflag = 1 ; Set exitflag == 1
Return
exit
endcase
case 1
endcase
Default
exitwhile
endcase
endswitch
endwhile
Endproc
;***********************************************************************
;** Procedure
;***********************************************************************
Proc Proc1
String List ; Text for the list box
string Var1 ; Text from dialog box "text1".
string Var2 ; Text from dialog box "text2".
string Var3 ; Text from dialog box "text3".
string Var4 ; Text from dialog box "text4" .
string Var5 ; Text from dialog box "text5" .
Integer Event
List = "A,B,C,D,E,F" ;List items
Label1: ;Label used to return to dialogbox if all parameters have not been entered and ok is selected.
dialogbox 0 15 29 274 184 27 "2nd dialogbox"
editbox 6 51 42 34 11 Var1
editbox 7 51 63 34 11 Var3
editbox 9 51 91 34 11 Var5
listbox 15 137 41 48 32 LIST SINGLE var2 sort
editbox 8 137 83 34 11 Var4
pushbutton 3 70 114 40 14 "&OK" OK DEFAULT
pushbutton 4 125 114 40 14 "&Cancel" CANCEL
text 10 2 88 42 17 "Enter value" left
text 12 4 41 34 17 "Enter value" left
text 11 5 63 34 11 "Enter value" left
text 2 37 21 106 11 "Enter value" left
text 13 188 50 78 17 "Enter value" left
text 14 179 83 34 11 "New value" left
enddialog
while 1 ;loop forever
dlgevent 0 Event ; Read dialog event.
switch Event ; Evaluate dialog event.
case 0
endcase
case 4 ;Cancel has been pressed return to main
dlgdestroy 0 CANCEL ; Destroy dialog box.
Return
endcase
case 6 ;edit box no 6 has been used
case 7 ; etc
case 8
case 9
case 15
endcase
case 3
exitwhile ; Exit the loop.
endcase
default
endcase
endswitch
endwhile
if not nullstr var1; See that var1 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
if not nullstr var2; See that var2 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
if not nullstr var3; See that var3 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
if not nullstr var4; See that var4 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
if not nullstr var5; See that var4 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
dlgdestroy 0 CANCEL ; Destroy dialog box.
Endproc
;********************************************************************
;** Procedure to create new extn range, i.e nex
;********************************************************************
Proc Proc2
Integer Event
string Var6
String Var7
Label2:
dialogbox 2 148 47 264 182 27 "3rd dialogbox"
editbox 30 122 37 34 11 Var6
editbox 31 122 92 34 11 Var7
pushbutton 32 74 139 40 13 "Ok" OK DEFAULT
pushbutton 33 151 139 40 13 "Cancel" CANCEL
text 34 51 92 65 20 "enter text" left
text 35 51 36 65 20 "enter text" left
text 36 48 10 176 11 "enter text" left
enddialog
while 1 ;loop forever
dlgevent 2 Event ; Read dialog event.
switch Event ; Evaluate dialog event.
case 0
endcase
case 33
dlgdestroy 2 CANCEL ; Destroy dialog box no 2.
Return ;Return to main
endcase
case 30 ;edit box no 30 has been used
case 31 ; etc
endcase
case 32
exitwhile ; Exit the loop.
endcase
default
endcase
endswitch
endwhile
if not nullstr var6; See that var6 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label2
endif
if not nullstr var7; See that var7 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label2
endif
dlgdestroy 2 CANCEL ; Destroy dialog box.
endproc
"pass_word" which checks the environment settings of a users pc and then
Compares this to entries in an array.
If the check is successful a dialog box is called. No problems up to here.
If a radio button is selected on the dialog box and the OK pushbutton is pressed,
Another dialog box is called.
However one of the edit boxes contains the text of the domain name, which was used in Proc "pass_word". How is this passed from one procedure to another, as the variables are all local? Also if a text is selected from a list box in dialog 3 this is passed to dialog 1 if cancel is selected.
If anyone can help it would be much appreciated,
I have posted a quick test script to explain a bit more.
Apologies for the programming, it's all new to me.
;************************** Global variables *******************************
Integer Choice
Integer Exitflag
proc main
;*********************** Define Local variables for Main Proc ****************
;****************************************************************************
;******************************** Password check **************************
;*** call procedure pass_word *****
;****************************************************************************
pass_word ()
;******************************** Inital Dialogbox *************************
;*** call procedure inital_user_selection () *****
;****************************************************************************
While 1
inital_user_selection () ;Call procedure inital_user_selection ()
;This calls a dialogbox for user selection
dlgdestroy 1 CANCEL ; Destroy the dialog box.
if exitflag == 1 ; If the Quit button from inital_user_selection ()
; is selected, it sets exitflag = 1, exitwhile.
exitwhile
endif
if Choice == 22 ; Evaluate radio group state from inital_user_selection ().
proc1 () ; Call procedure
endif
if Choice == 23 ; Evaluate radio group state from inital_user_selection ().
proc2 () ; Call procedure
endif
endwhile
exit ;exit script
Endproc ;end main proc
;******************************************************************************************************
;****************************** Procdeures *******************************************************
;******************************************************************************************************
Proc pass_word
string compname
string compdomain
integer cnt
integer flag = 1
string pass[2]
pass[0] = "Flynn GavinAU01A"
pass[1] = "Bloggs JoeAU01A"
getenv "username" compname ; Get the variable from env i.e same as using SET at the CMD prompt.
getenv "userdomain" compdomain ; Get username from env and domain name
strcat compname compdomain ; Concatenates the two strings into string companme
breakpoint
while cnt <2 && flag !=0 ; If more users are added increase cnt loop,
;
strcmp compname pass[cnt] flag ; Performs a case-sensitive comparison on the two strings
; flag will be set to 0 if the strings are identical.
cnt=cnt + 1 ; Increment cnt
endwhile
if flag == 0 ; check the staus of flag return to main proc if flag = 0
; i.e password/user is valid
Return
else ; otherwise display message and exit script if flag !=0
; i.e if password/user is not valid
errormsg "You are not Authorised to use this script " Compname
Exit ;exit the script
endif
Endproc
;*************************************************************************************************
;*** Call Inital dialogue Box to allow user to select a Radio button *********
;*** Evaluate the selection and call the relevant procedure *********
;*************************************************************************************************
Proc inital_user_selection
integer Event ; Dialog box event
dialogbox 1 34 19 470 292 27 " Quick test"
radiogroup 1 choice
radiobutton 22 43 32 101 11 "Button1"
radiobutton 23 43 47 120 11 "Button2"
endgroup
pushbutton 20 142 252 40 13 "Ok" OK DEFAULT
pushbutton 21 220 251 40 13 "Quit" CANCEL
enddialog
while 1 ;loop forever
dlgevent 1 Event ; Read dialog event.
switch Event ; Evaluate dialog event.
case 0 ; No event do nothing
endcase
case 21 ; Cancel selected
Exitflag = 1 ; Set exitflag == 1
Return
exit
endcase
case 1
endcase
Default
exitwhile
endcase
endswitch
endwhile
Endproc
;***********************************************************************
;** Procedure
;***********************************************************************
Proc Proc1
String List ; Text for the list box
string Var1 ; Text from dialog box "text1".
string Var2 ; Text from dialog box "text2".
string Var3 ; Text from dialog box "text3".
string Var4 ; Text from dialog box "text4" .
string Var5 ; Text from dialog box "text5" .
Integer Event
List = "A,B,C,D,E,F" ;List items
Label1: ;Label used to return to dialogbox if all parameters have not been entered and ok is selected.
dialogbox 0 15 29 274 184 27 "2nd dialogbox"
editbox 6 51 42 34 11 Var1
editbox 7 51 63 34 11 Var3
editbox 9 51 91 34 11 Var5
listbox 15 137 41 48 32 LIST SINGLE var2 sort
editbox 8 137 83 34 11 Var4
pushbutton 3 70 114 40 14 "&OK" OK DEFAULT
pushbutton 4 125 114 40 14 "&Cancel" CANCEL
text 10 2 88 42 17 "Enter value" left
text 12 4 41 34 17 "Enter value" left
text 11 5 63 34 11 "Enter value" left
text 2 37 21 106 11 "Enter value" left
text 13 188 50 78 17 "Enter value" left
text 14 179 83 34 11 "New value" left
enddialog
while 1 ;loop forever
dlgevent 0 Event ; Read dialog event.
switch Event ; Evaluate dialog event.
case 0
endcase
case 4 ;Cancel has been pressed return to main
dlgdestroy 0 CANCEL ; Destroy dialog box.
Return
endcase
case 6 ;edit box no 6 has been used
case 7 ; etc
case 8
case 9
case 15
endcase
case 3
exitwhile ; Exit the loop.
endcase
default
endcase
endswitch
endwhile
if not nullstr var1; See that var1 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
if not nullstr var2; See that var2 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
if not nullstr var3; See that var3 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
if not nullstr var4; See that var4 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
if not nullstr var5; See that var4 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label1
endif
dlgdestroy 0 CANCEL ; Destroy dialog box.
Endproc
;********************************************************************
;** Procedure to create new extn range, i.e nex
;********************************************************************
Proc Proc2
Integer Event
string Var6
String Var7
Label2:
dialogbox 2 148 47 264 182 27 "3rd dialogbox"
editbox 30 122 37 34 11 Var6
editbox 31 122 92 34 11 Var7
pushbutton 32 74 139 40 13 "Ok" OK DEFAULT
pushbutton 33 151 139 40 13 "Cancel" CANCEL
text 34 51 92 65 20 "enter text" left
text 35 51 36 65 20 "enter text" left
text 36 48 10 176 11 "enter text" left
enddialog
while 1 ;loop forever
dlgevent 2 Event ; Read dialog event.
switch Event ; Evaluate dialog event.
case 0
endcase
case 33
dlgdestroy 2 CANCEL ; Destroy dialog box no 2.
Return ;Return to main
endcase
case 30 ;edit box no 30 has been used
case 31 ; etc
endcase
case 32
exitwhile ; Exit the loop.
endcase
default
endcase
endswitch
endwhile
if not nullstr var6; See that var6 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label2
endif
if not nullstr var7; See that var7 isn't empty.
else
usermsg "Enter all Parameters."
Goto Label2
endif
dlgdestroy 2 CANCEL ; Destroy dialog box.
endproc