1. comparing a field fo 0 thru 9 values

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.&nbsp; 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 = "#"&gt;500"</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;lsi = length(seqseq)<BR>&nbsp;&nbsp;for si = 
1 to length( seqseq) do<BR>&nbsp;&nbsp;&nbsp;if not integer(seqseq[si]) 
then<BR>&nbsp;&nbsp;--if compare(seqseq[si], "0" ) &gt; 0 then&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;seqseq[si] = "0"<BR>&nbsp;&nbsp;end if<BR>&nbsp;&nbsp;end 
if<BR>&nbsp;&nbsp;--if compare(seqseq[si], "9" ) = 0 then&nbsp; 
<BR>&nbsp;&nbsp;--&nbsp;seqseq[si] = "0"<BR>&nbsp;--&nbsp;end 

------=_NextPart_000_0006_01C395B1.0E0C4120--

new topic     » topic index » view message » categorize

2. Re: comparing a field fo 0 thru 9 values

----- 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

new topic     » goto parent     » topic index » view message » categorize

3. Re: comparing a field fo 0 thru 9 values

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
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: comparing a field fo 0 thru 9 values

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: comparing a field fo 0 thru 9 values

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: comparing a field fo 0 thru 9 values

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!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu