1. Re: Short Circuiting
- Posted by Joe Phillips <bubba at TXWES.EDU> Jun 23, 1998
- 407 views
- Last edited Jun 24, 1998
At 07:56 PM 6/23/98 -0400, you wrote: >>Boom! As soon as a length < 3 comes along, the code crashes. So it's >>modified to: >> >> if length( s ) > 2 then >> if compare( s[1..3], "EOF" ) = 0 then >> ... >> end if >> else >> ... >> end if >> >>Only now, I'm stuck not being able to get to the 'else' portion of the >>logic. Grrr... > To get the above code to work, you could create a function into which you send s. This would provide a single point of logic that would allow a simple if-then-else structure as you desire. (Although a short-circuit logic would be cleaner) ( the extra sequence s2 allows allows flexibility ) check_s( sequence s1, sequence s2) if length(s1)>= length(s2) then if compare(s1[1..length(s2)],s2) then return true end if end if return false end procedure if check_s(s,"EOF") then . . else . . end if Joe Phillips, Assistant Director Information Technology Services Texas Wesleyan University 817-531-4284