I wish to examine the value in a variable "tStatus" which may hold one of three strings. I have three ways of doing this; two use the if statement and one the the Switch construct. For some reason I resist using Switch statements as I think I was told years ago that they were not efficient. So which of these examples would you use ?
Code: Select all
If tStatus is "Invalid" then
put false into tResultsA ["ValidFileType"]
Return tResultsA
end if
If tStatus is "LittleEndian" then put true into tIsLittleEndian
If tStatus is "BigEndian" then put false into tIsLittleEndian
## OR ##
If tStatus is "Invalid" then
put false into tResultsA ["ValidFileType"]
Return tResultsA
end if
If tStatus is "LittleEndian" then
put true into tIsLittleEndian
else
put false into tIsLittleEndian
end if
## OR ##
Switch tStatus
Case "Invalid"
put false into tResultsA ["ValidFileType"]
Return tResultsA
break
Case "LittleEndian"
put true into tIsLittleEndian
break
Case "BigEndian"
put false into tIsLittleEndian
break
end Switch