or condition error in script
Elden Paul Iverson wrote on May 09, 2008
Frank-
I have recently encountered a problem when writing an iraf script that displays images and then allows the user to delete select files. The portion of the script that is having errors is below. The script enters the first while loop and, since del_num = "" to start, it also enters the second. However, when the value of del_num is changed to "Next" or "Finish" it will not quit the loop. Furthermore, the script will also enter the if statement despite the value of del_num. We seem to have some problem with the || in both the while loop and if statement but we don't know why. Can you shed any light on this?
Thanks.
-Paul
I have recently encountered a problem when writing an iraf script that displays images and then allows the user to delete select files. The portion of the script that is having errors is below. The script enters the first while loop and, since del_num = "" to start, it also enters the second. However, when the value of del_num is changed to "Next" or "Finish" it will not quit the loop. Furthermore, the script will also enter the if statement despite the value of del_num. We seem to have some problem with the || in both the while loop and if statement but we don't know why. Can you shed any light on this?
Thanks.
-Paul
while (del_file=="Yes"){
while (del_num!="Next" || del_num!="Finish"){
clear
list1="datacheck"
while (fscan(list1,s1,s2)!=EOF){
numbers=(s1)
files=(s2)
print ("["//numbers//"] "//files)
}
print ("")
ap_imagecheck.delete_file_num=""
del_num=delete_file_num
clear
print ("del_num = ",del_num)
sleep (5)
if (del_num!="Next" || del_num!="Finish"){
list1="datacheck"
while (fscan(list1,s1,s2)!=EOF){
numbers=(s1)
files=(s2)
if (del_num==numbers){
delete (files)
}
;
if (del_num!=numbers){
print (i//" "//files,>>"datachecktemp")
i=i+1
}
;
}
delete ("datacheck")
rename ("datachecktemp","datacheck")
i=1
clear
print ("I am here")
sleep (3)
}
;
}
if (del_num=="Next"){
del_file="No"
}
;
if (del_num=="Finish"){
del_file="Finish"
}
;
clear
print ("del_file = ",del_file)
sleep (5)
}
Mike Fitzpatrick wrote on May 09, 2008
If del_num is 'Next' then the "del_num!="Finish"' will always be true, and vice versa. The condition boils down to "while (true || false)" or "while (false || true", the
OR means it will always be true and so the loop continues.
-Mike
OR means it will always be true and so the loop continues.
-Mike
Last post on May 09, 2008