1. Valid command form?
- Posted by Steven G Astley <sgastley at HOTMAIL.COM> Jan 10, 2000
- 511 views
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 =============================================================== object w 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")=0 then puts(1,"2EQ ") else puts(1,"2NQ ") end if puts1,"\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")=0 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")=0 then puts(1,"4EQ ") else puts(1,"4NQ ") end if ==================================================================== RESULTS= r : 1EQ r : 2NQ 2NQ 2EQ r1g : 3NQ 3NQ 3EQ r1g : 4NQ 4NQ 4EQ ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
2. Re: Valid command form?
- Posted by Irv Mullins <irv at ELLIJAY.COM> Jan 10, 2000
- 485 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
3. Re: Valid command form?
- Posted by JJProg at CYBERBURY.NET Jan 10, 2000
- 466 views
- Last edited Jan 11, 2000
EU>is command valid/supported: "if equal(s[1],"r")=0 then ..."? Its the ONLY EU>way i can get the evaluation performed. Any help would be greatly EU>appreciated. thanks EU>=============================================================== EU>object w EU>sequence s --s can be variable length (1 to 3 bytes) EU>s="r" puts(1,s) puts(1," : ") EU>if equal(s,"r") then puts(1,"1EQ ") else puts(1,"1NQ ") end if EU>puts(1,"\n") ¦ EU>s="r" puts(1,s) puts(1," : ") EU>if equal(s[1],"r") then puts(1,"2EQ ") else puts(1,"2NQ ") end if EU>if compare(s[1],"r")=0 then puts(1,"2EQ ") else puts(1,"2NQ ") end if EU>if equal(s[1],"r")=0 then puts(1,"2EQ ") else puts(1,"2NQ ") end if EU>puts1,"\n") EU>s="r1g" puts(1,s) puts(1," : ") EU>if equal(s[1],"r") then puts(1,"3EQ ") else puts(1,"3NQ ") end if if EU>compare(s[1],"r")=0 then puts(1,"3EQ ") else puts(1,"3NQ ") end if EU>if equal(s[1],"r")=0 then puts(1,"3EQ ") else puts(1,"3NQ ") end if EU>puts(1,"\n") EU>s="r1g" puts(1,s) puts(1," : ") EU>if length(s)>1 then ws=s[1] else ws=s end if EU>if equal(ws,"r") then puts(1,"4EQ ") else puts(1,"4NQ ") end if EU>if compare(ws,"r")=0 then puts(1,"4EQ ") else puts(1,"4NQ ") end if if EU>equal(ws,"r")=0 then puts(1,"4EQ ") else puts(1,"4NQ ") end if EU>==================================================================== EU>RESULTS= EU>r : 1EQ r : EU> 2NQ 2NQ 2EQ EU>r1g : 3NQ 3NQ 3EQ EU>r1g : 4NQ 4NQ 4EQ EU>______________________________________________________ EU>Get Your Private, Free Email at http://www.hotmail.com If s is a one-dimensional sequence (a string, for example), you must use single quoutes instead of double quotes. For example: if s[1] = 'r' then ... Jeffrey Fielding JJProg at cyberbury.net http://members.tripod.com/~JJProg/