RE: if statement not working
- Posted by bensler at mail.com Mar 21, 2002
- 457 views
Andy Serpa wrote: > > xxmyt at yahoo.com wrote: > > hello everyone. > > > > the code i pasted down works properly. however, it doesnt work in the > > second way. > > > > my code: > > include dos32lib.e > > without warning > > > > constant > > Win = create( Window, "PASSWORD REQUIRED", 0, Default, Default, > > 400, 200, 0 ), > > > > Sle1 = create( EditText, "", Win, 10, 40, 120, 20, 0 ), > > Button1 = create( PushButton, "OK", Win, 180, 40, 120, 20, 0 ) > > > > > > procedure onClick_Button1() > > > > if equal(getText(Sle1),"YES") then > > closeWindow(Win) > > end if > > > > end procedure > > > > onClick[Button1] = routine_id("onClick_Button1") > > > > WinMain( Win ) > > > > but if i change the if statement this way, i get an error message: > > > > if getText(Sle1) = "YES" then > > closeWindow(Win) > > end if > > > > error message says, the result of the if statemnt should be an atom. > > > > so whats it all about? > > > > It means to compare sequences, and therefore any string, you have to use > > the "equal" or "compare" statements, not = < > !=. > > Using the latter operators on a sequence is for expressions, and > compares each element of a sequence to its counterpart in another > sequence of equal length. For instance, > > s = {8,9,10} = {8,4,10} > > Now s is {1,0,1}. > > This facility is very useful, but can make if statements involving > sequences a bit non-intuitive. Anyway, you gotta use equal & compare.. > Could you give an example of how that might be useful? I understand the concept, but I can't wrap my brain around how I could use it. btw: That assignment statement is easier to understand if written: s = ({8,9,10} = {8,4,10}) Chris