Re: ES_NUMERIC

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

23/10/2002 5:19:13 PM, petelomax at blueyonder.co.uk wrote:

>>
>So, in:
>  constant vMaxSize = {9999,    4,    5,   19}
>        if length(getText(self)) >= vMaxSize[find(self, vFldSize)+1] 
>
>can I assume the 9999 & the +1 are unnecessary (but cause no harm)?
>

Well "unnecessary" isn't the right word really. What it does show is my laziness
(a.k.a. terse
coding style). 
I need vMaxSize to have one more element than the number of fields to check.
This is because I use
the find() function to locate the fld id to check. If the field being checked
isn't in the list of
'sized' fields, then find() will return a zero. So all I do is add one to
whatever find() returns
and use that as an index into the vMaxSize list. The first (zero'th item) is
always ignored unless I
try to check a field that isn't supposed to be checked - in which case the
maxsize is a huge number
(9999). 

The other way to code it would be...

  integer tempval
  tempval = find(self, vFldSize)
  if tempval > 0 then
      if length(getText(self)) >= vMaxSize[tempval] then 
          returnValue(-1)
      end if
  end if

My method saves a temporary variable and only uses one line of code. It is
however ever so slightly
slower when an incorrect field is being checked - but that shouldn't happen ,
right? blink.

---------
Cheers,
Derek Parnell

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

Search



Quick Links

User menu

Not signed in.

Misc Menu