Re: Valid command form?
- Posted by Irv Mullins <irv at ELLIJAY.COM> Jan 10, 2000
- 486 views
On Mon, 10 Jan 2000, you wrote: > is command valid/supported: "if equal(s[1],"r")=0 then ..."? Its the ONLY > way i can get the evaluation performed. Any help would be greatly > appreciated. thanks 1. If you are interested in seeing if a single character equals another single character, you should write it as a single character: 'r' See code below. 2. You wrote: if equal(s[1],"r")=0 then puts(1,"2EQ ") .... This means "if s[1] equals "r" is false then puts ("Equal")" which is probably not what you want. Try losing the =0 -- Tested code: object ws sequence s --s can be variable length (1 to 3 bytes) s="r" puts(1,s) puts(1," : ") if equal(s,"r") then puts(1,"1EQ ") else puts(1,"1NQ ") end if puts(1,'\n') s="r" puts(1,s) puts(1," : ") if equal(s[1],'r') then puts(1,"2EQ ") else puts(1,"2NQ ") end if if compare(s[1],'r')=0 then puts(1,"2EQ ") else puts(1,"2NQ ") end if if equal(s[1],'r') then puts(1,"2EQ ") else puts(1,"2NQ ") end if puts(1,'\n') s="r1g" puts(1,s) puts(1," : ") if equal(s[1],'r') then puts(1,"3EQ ") else puts(1,"3NQ ") end if if compare(s[1],'r')=0 then puts(1,"3EQ ") else puts(1,"3NQ ") end if if equal(s[1],'r') then puts(1,"3EQ ") else puts(1,"3NQ ") end if puts(1,'\n') s="r1g" puts(1,s) puts(1," : ") if length(s)>1 then ws=s[1] else ws=s end if if equal(ws,'r') then puts(1,"4EQ ") else puts(1,"4NQ ") end if if compare(ws,'r')=0 then puts(1,"4EQ ") else puts(1,"4NQ ") end if if equal(ws,'r') then puts(1,"4EQ ") else puts(1,"4NQ ") end if -- RESULTS: r : 1EQ r : 2EQ 2EQ 2EQ r1g : 3EQ 3EQ 3EQ r1g : 4EQ 4EQ 4EQ Irv