1. comparing a field fo 0 thru 9 values
- Posted by "sixs" <sixs at ida.net> Oct 19, 2003
- 415 views
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C395B1.0E0C4120 charset="iso-8859-1" I am trying to check a field to see if the values are all numeric, not 0 thru 9. I haven't been successful in correctly checking for these values and replacing all non characters with zeros. Jvandal ====================================== sequence seqseq seqseq = "#">500" lsi = length(seqseq) for si = 1 to length( seqseq) do if not integer(seqseq[si]) then --if compare(seqseq[si], "0" ) > 0 then seqseq[si] = "0" end if end if --if compare(seqseq[si], "9" ) = 0 then -- seqseq[si] = "0" -- end if ------=_NextPart_000_0006_01C395B1.0E0C4120 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 8bit <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.2800.1264" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Arial size=2>I am trying to check a field to see if the values are all numeric, not 0 thru 9. I haven't been successful in correctly checking for these values and replacing all non characters with zeros.</FONT></DIV> <DIV><FONT face=Arial size=2>Jvandal</FONT></DIV> <DIV><FONT face=Arial size=2>======================================</FONT></DIV> <DIV><FONT face=Arial size=2>sequence seqseq</FONT></DIV> <DIV><FONT face=Arial size=2>seqseq = "#">500"</FONT></DIV> <DIV><FONT face=Arial size=2> lsi = length(seqseq)<BR> for si = 1 to length( seqseq) do<BR> if not integer(seqseq[si]) then<BR> --if compare(seqseq[si], "0" ) > 0 then <BR> seqseq[si] = "0"<BR> end if<BR> end if<BR> --if compare(seqseq[si], "9" ) = 0 then <BR> -- seqseq[si] = "0"<BR> -- end ------=_NextPart_000_0006_01C395B1.0E0C4120--
2. Re: comparing a field fo 0 thru 9 values
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 20, 2003
- 406 views
----- Original Message ----- From: sixs Subject: comparing a field fo 0 thru 9 values I am trying to check a field to see if the values are all numeric, not 0 thru 9. I haven't been successful in correctly checking for these values and replacing all non characters with zeros. Jvandal ====================================== sequence seqseq seqseq = "#">500" lsi = length(seqseq) for si = 1 to length( seqseq) do if not integer(seqseq[si]) then --if compare(seqseq[si], "0" ) > 0 then seqseq[si] = "0" end if end if --if compare(seqseq[si], "9" ) = 0 then -- seqseq[si] = "0" -- end if ----------Derek's Response ------------ sequence seqseq seqseq = "#\">500" for si = 1 to length( seqseq) do if not find(seqseq[si],"0123456789") then seqseq[si] = '0' end if end for
3. Re: comparing a field fo 0 thru 9 values
- Posted by Euphoria <l3euphoria at bellsouth.net> Oct 20, 2003
- 391 views
Hey look, Neat trick. sequence list list = {1, 2, 3, 4, 5, 6 , 7, 8, 9, 10} ? remainder(list, 1) -- and according to this trick. global type integers(object list)-- whole numbers, not limited to 31-bit integer sequence mask, zeros if atom(list) then return 0 end if mask = remainder(list, 1) zeros = repeat(0, length(list)) -- {0,0,0,...} return equal(mask, zeros) end type So, for your case, you can do. --WARNING: I think the method below will be slower. --This is more of a novelty. It should be time tested. --Copy with comments below this straight forward code. --------------- -- Pure code -- --------------- sequence seqseq, mask seqseq = "#">500" mask = (seqseq >= '0') mask = (mask and ('9' >= seqseq)) mask = (mask and (remainder(seqseq, 1) = 0)) seqseq *= mask mask = (mask = 0) mask *= '0' seqseq += mask --------------------- -- Comment Version -- --------------------- sequence seqseq, mask seqseq = "#">500" mask = (seqseq >= '0') -- filter out smaller than '0' mask = (mask and ('9' >= seqseq)) -- filter out bigger than '9' mask = (mask and (remainder(seqseq, 1) = 0)) -- filter out floats (4.5) --Apply filter to seqseq --filtered out values are set to 0 not '0' seqseq *= mask -- invert mask, 1's become 0's and 0's become 1's mask = (mask = 0) -- set the new 1's to '0' mask *= '0' -- set 1's to '0' -- apply '0' mask seqseq += mask Lucius L. Hilley III - Unkmar Derek Parnell wrote: > > > ----- Original Message ----- > From: sixs > To: EUforum at topica.com > Sent: Sunday, October 19, 2003 11:50 AM > Subject: comparing a field fo 0 thru 9 values > > > I am trying to check a field to see if the values are all numeric, not 0 thru > 9. I haven't been successful in correctly checking for these values and > replacing all non characters with zeros. > Jvandal > ====================================== > sequence seqseq > seqseq = "#">500" > lsi = length(seqseq) > for si = 1 to length( seqseq) do > if not integer(seqseq[si]) then > --if compare(seqseq[si], "0" ) > 0 then > seqseq[si] = "0" > end if > end if > --if compare(seqseq[si], "9" ) = 0 then > -- seqseq[si] = "0" > -- end if > > ----------Derek's Response ------------ > sequence seqseq > seqseq = "#\">500" > for si = 1 to length( seqseq) do > if not find(seqseq[si],"0123456789") then > seqseq[si] = '0' > end if > end for >
4. Re: comparing a field fo 0 thru 9 values
- Posted by Euphoria <l3euphoria at bellsouth.net> Oct 20, 2003
- 402 views
I didn't think about this. Chris Bensler brought this to my attention. -- whole numbers, not limited to 31-bit integers global type integers(object list) return equal(list, floor(list)) end type So, for your case, you can do. seqseq = "#">500" mask = (seqseq >= '0') mask = (mask and ('9' >= seqseq)) mask = (mask and (list = floor(list))) seqseq *= mask mask = (mask = 0) mask *= '0' seqseq += mask Lucius L. Hilley III - Unkmar
5. Re: comparing a field fo 0 thru 9 values
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Oct 20, 2003
- 391 views
On Mon, 20 Oct 2003 14:13:34 -0400, Lucius Hilley <l3euphoria at bellsouth.net> wrote: >--WARNING: I think the method below will be slower. >--This is more of a novelty. It should be time tested. So I just had to test it then, didn't I? Turns out it is around four times slower than dp's code. OTOH, your code will quite happily cope with say {"a1","a2"}, returning {"01","02"}, whereas dp's does not cater for that and in fact will just return "00" (which of course might in fact be what is wanted). Pete
6. Re: comparing a field fo 0 thru 9 values
- Posted by "Louis Puster" <Louis at cwshop.com> Oct 20, 2003
- 387 views
I couldn't resist. Here is my solution. It might be the fastest of all? The output is in 'list': sequence seqseq, mask, list seqseq = "#\">500" mask = (seqseq >= '0') and (seqseq <= '9') list = mask * seqseq + not mask * '0' Louis. *********** REPLY SEPARATOR *********** On 10/20/2003 at 4:42 PM Lucius Hilley wrote: > > >I didn't think about this. Chris Bensler brought this to my attention. > >-- whole numbers, not limited to 31-bit integers >global type integers(object list) > return equal(list, floor(list)) >end type > >So, for your case, you can do. > >seqseq = "#">500" >mask = (seqseq >= '0') >mask = (mask and ('9' >= seqseq)) >mask = (mask and (list = floor(list))) > >seqseq *= mask > >mask = (mask = 0) >mask *= '0' > >seqseq += mask > > > Lucius L. Hilley III - Unkmar > > > >TOPICA - Start your own email discussion group. FREE!