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!

setjmp and longjmp commands Help.....

Status
Not open for further replies.

Woodro

Technical User
Jul 31, 2002
78
US
I need this program to look at the if then statments multiple times. As you can see the program calls up a proc
then needs to go back to the top of the if then statements only this time around carrying a different value for the variable it already checked so that it doesn't check it twice and proceeds on to the next else statement. How can
this be written to accomplish this. Thanks....Woodro


proc main

integer event
integer CDP=0
integer FCAS=0
integer FSNS=0
integer NCTL=0
integer Var1=0
;==================================
;DIALOG BOXES GATHERING INFORMATION 2
;==================================
dialogbox 0 167 77 376 136 3 "GATHERINIG ESN INFORMATION.........."
text 1 5 2 98 11 "LD-87 Selections:" left

checkbox 3 5 13 41 11 "CDP" CDP
checkbox 4 5 27 41 11 "FCAS" FCAS
checkbox 5 5 39 41 11 "FSNS" FSNS
checkbox 6 5 52 41 11 "NCTL" NCTL
pushbutton 45 257 104 40 13 "CANCEL" CANCEL
pushbutton 46 305 104 40 13 "OK" OK DEFAULT
enddialog




while 1
dlgevent 0 event
switch event
case 0 ;No event occurred.

endcase
case 3
case 4
case 5
case 6

endcase
default
exitwhile
endcase

endswitch


endwhile
dlgdestroy 0 cancel


;testing values of esn gate openers
;==============================================
usermsg "CDP=%d" CDP
usermsg "FCAS=%d" FCAS
usermsg "FSNS=%d" FSNS
usermsg "NCTL=%d" NCTL
;==============================================

setjmp 0 Var1

if cdp==1
call cdpproc
elseif FCAS==1
call fcasproc
elseif FSNS==1
call fsnsproc
elseif NCTL==1
call nctlproc
else

usermsg "Go to other program"
endif

usermsg "This will start the next ESN Choices"
endproc

proc cdpproc
integer Var1 = 0
;if Var1=1
usermsg "CDP program will now run"
cdp = 0

;else
longjmp 0 Var1
;endif

endproc

proc fcasproc
usermsg "FCAS program will now run"
endproc

proc fsnsproc
usermsg "FSNS program will run"
endproc

proc nctlproc
usermsg "NCTL program will run"
endproc


Woodro
 
If the additional input will continue to come from the dialog, then you'll want to move the setjmp command prior to the while 1 loop. You could also enclose the majority of your main script instead a while 1/endwhile loop, then add some check to exit the script when the cancel button in the dialog is closed (I think you may have this already, but am a little pressed for time to check at the moment).


aspect@aspectscripting.com
 
Knob, If I check the CDP box and the FCAS box then both are equal to 1. So CDP is 1 its first time thru.What I'd like to do is change the value of CDP to zero after the called proc is done.Then pass that value (Zero) back to the main proc. Then since cdp will be 0 and FCAS will be 1, the if then will skip over the cdp and the FCAS proc can fire off and the same process can take place till they are all done.
Is there a better way to approach this? I have 25 or 30 different procedures that will have check boxes in that first dialog box. Is there a better way? Once all the proc are checked that need to run the dialog box can go away and the programs start running.
Thanks
Woodro


Woodro
 
Instead of doing else/elseif/etc. like you are doing now (which only results in one procedure being called), I would use a separate if/endif for each variable you need to check. That way all of the checked variables will be run, one after another, when the dialog box has been closed.

aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top