Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialogbox

Status
Not open for further replies.

iSDX

Technical User
Jul 24, 2002
64
AU
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 &quot;You are not Authorised to use this script &quot; 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 &quot; Quick test&quot;
radiogroup 1 choice
radiobutton 22 43 32 101 11 &quot;Button1&quot;
radiobutton 23 43 47 120 11 &quot;Button2&quot;

endgroup
pushbutton 20 142 252 40 13 &quot;Ok&quot; OK DEFAULT
pushbutton 21 220 251 40 13 &quot;Quit&quot; 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 &quot;text1&quot;.
string Var2 ; Text from dialog box &quot;text2&quot;.
string Var3 ; Text from dialog box &quot;text3&quot;.
string Var4 ; Text from dialog box &quot;text4&quot; .
string Var5 ; Text from dialog box &quot;text5&quot; .
Integer Event


List = &quot;A,B,C,D,E,F&quot; ;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 &quot;2nd dialogbox&quot;
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 &quot;&OK&quot; OK DEFAULT
pushbutton 4 125 114 40 14 &quot;&Cancel&quot; CANCEL
text 10 2 88 42 17 &quot;Enter value&quot; left
text 12 4 41 34 17 &quot;Enter value&quot; left
text 11 5 63 34 11 &quot;Enter value&quot; left
text 2 37 21 106 11 &quot;Enter value&quot; left
text 13 188 50 78 17 &quot;Enter value&quot; left
text 14 179 83 34 11 &quot;New value&quot; 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 &quot;Enter all Parameters.&quot;
Goto Label1
endif

if not nullstr var2; See that var2 isn't empty.

else
usermsg &quot;Enter all Parameters.&quot;
Goto Label1
endif

if not nullstr var3; See that var3 isn't empty.

else
usermsg &quot;Enter all Parameters.&quot;
Goto Label1
endif

if not nullstr var4; See that var4 isn't empty.

else
usermsg &quot;Enter all Parameters.&quot;
Goto Label1
endif

if not nullstr var5; See that var4 isn't empty.

else
usermsg &quot;Enter all Parameters.&quot;
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 &quot;3rd dialogbox&quot;
editbox 30 122 37 34 11 Var6
editbox 31 122 92 34 11 Var7
pushbutton 32 74 139 40 13 &quot;Ok&quot; OK DEFAULT
pushbutton 33 151 139 40 13 &quot;Cancel&quot; CANCEL
text 34 51 92 65 20 &quot;enter text&quot; left
text 35 51 36 65 20 &quot;enter text&quot; left
text 36 48 10 176 11 &quot;enter text&quot; 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 &quot;Enter all Parameters.&quot;
Goto Label2
endif

if not nullstr var7; See that var7 isn't empty.

else
usermsg &quot;Enter all Parameters.&quot;
Goto Label2
endif

dlgdestroy 2 CANCEL ; Destroy dialog box.



endproc





 

Not sure if this what you need but this is how you can pass values from one procedure to another.

proc main
string sParam1

sParam1 = &quot;Value&quot;
mySub(sParam1)
endproc

proc mySub
param string sParam1

usermsg sParam1
endproc
 
Thanks for the advice.

Unfortunately I have the problem were values are been
passed from one procedure to another and I'm confused to how this is happening.

A string defined as compdomain in proc Pass_word () has a value
stored here, after this proc has finished this value is passed to
Proc 1 ? and a string var1 in proc 1 has the value equal to compdomain.

This all seems scatty, I know, any further help would be appreciated.
 
Ignore all of the above; I have not initialised the variables in my procedures,
So I expect that the values from memory are being passed. Once I initalise
the variables to &quot;&quot;, all works fine.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top