Re: type string

new topic     » topic index » view thread      » older message » newer message

Mike <michael at IGRIN.CO.NZ> wrote:

>Hey guys,
>    why not try using:
>
>if c < 0 then
>    return 0
>elsif c > 255 then
>    return 0
>end if
>
>instead of:
>
>if (c < 0) or (c > 255) then
>    return 0
>end if


Mike -- I included your idea with a few of mine, and came up with a routine
that's the fastest yet, while still allowing *any* object to be passed in as
a parm:


global type string12(object x)
sequence s
   if not sequence(x) then
      return 0
   end if
   s = x -- this is key
   for i = 1 to length(s) do
      x = s[i]
      if integer(x) then
         if x < 1 then
            return 0
         elsif x > 255 then
            return 0
         end if
      else
         return 0
      end if
   end for
   return 1
end type


Be seeing you,
   Gabriel Boehme


 -------
The obligatory quote:

The work of one supports the work of all.

Robert Fripp
 -------

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu