The use of nested if statements.

greenspun.com : LUSENET : Tool Command Language (Tcl) : One Thread

I am attempting to modify some of my projects current tcl scripts. I am atempting to insert variables so that we can put the code under source control where it requestingthe information that we currently insert when running a test. I am attempting to insert variables within nested if statements but when I run it, it appears to work but it doesn't exit out of the first if statement if it was originally true without going through all of its false options.Following is an example of what I have been working with/attempting to do.

set A after-hours-repair set B standby set C after-hours-standby set D test set E manager-initiated-test set F dispatch set G no-access set H delayed-maintenance set A1 provided set B1 denied

puts "Enter the Manager Response State to the Activity:

provided denied "

gets stdin response puts "The State that you entered was that of $response."

#puts "Enter the Type of Request that is being responded too: # # after-hours-repair # standby # after-hours-standby # test # manager-initiated-test # dispatch # no-access # delayed-maintenance # release # " # #gets stdin activity #puts "The Type of Request that you entered was $activity." #

if { $A1 == $response } {

puts "Enter the Type of Request that is being responded too:

after-hours-repair standby after-hours-standby test manager-initiated-test dispatch no-access delayed-maintenance release "

gets stdin activity puts "The Type of Request that you entered was $activity."

if {[ string match $A $activity ]} {

set replaceList { authorizationList {{{ state provided, tYpe {after-hours-repair}, authTime "19991022170305.0Z", authPerson { nUmber "C1_AP_Num", name "C1 AP Name", phone "3035953434", loc { civicAddress "C1 AA Street", city "Thornton", state "CO", zip "80200" }, email "C1_AP_Email", fax "3035926259", respon "C1_AP_Respon" } }} }}

puts "You approved request with an Activity of $activity." #return

} elseif {[ string match $B $activity ]} {

set replaceList { authorizationList {{{ state provided, tYpe {standby}, authTime "19991022170305.0Z", authPerson { nUmber "C1_AP_Num", name "C1 AP Name", phone "3035953434", loc { civicAddress "C1 AA Street", city "Thornton", state "CO", zip "80200" }, email "C1_AP_Email", fax "3035926259", respon "C1_AP_Respon" } }} }}

puts "You approved request with an Activity of $activity." #return

} else { puts " You have an incorrect activity, Try Again." return }} else {{ #} # # puts "you denied activity" # return #} #

puts "Enter the Type of Request that is being responded too:

after-hours-repair standby after-hours-standby test manager-initiated-test dispatch no-access delayed-maintenance release "

gets stdin activity puts "The Type of Request that you entered was $activity."

if {[ string match $A $activity ]} {

set replaceList { authorizationList {{{ state denied, tYpe {after-hours-repair}, authTime "19991022170305.0Z", authPerson { nUmber "C1_AP_Num", name "C1 AP Name", phone "3035953434", loc { civicAddress "C1 AA Street", city "Thornton", state "CO", zip "80200" }, email "C1_AP_Email", fax "3035926259", respon "C1_AP_Respon" } }} }}

puts "You denied request with an Activity of $activity." #return

} elseif {[ string match $B $activity ]} {

set replaceList { authorizationList {{{ state denied, tYpe {standby}, authTime "19991022170305.0Z", authPerson { nUmber "C1_AP_Num", name "C1 AP Name", phone "3035953434", loc { civicAddress "C1 AA Street", city "Thornton", state "CO", zip "80200" }, email "C1_AP_Email", fax "3035926259", respon "C1_AP_Respon" } }} }}

puts "You denied request with an Activity of $activity." #return

} else {

puts " You have an incorrect activity, Try Again." return } #} puts "You have Succeeded, Horray" return #} #

I would appreciate any assistance this matter.

-- David Hinrichs (dhinric@uswest.com), November 01, 2000

Answers

Which of the if statements is giving you the problem?

-- Larry W. Virden (lvirden@cas.org), December 02, 2000.

Moderation questions? read the FAQ