Quiz time -- "euronum" edit

Kenneth Brody kenbrody at bestweb.net
Tue Aug 16 13:15:06 PDT 2005


Quoting Lerebours, Jose (Tue, 16 Aug 2005 14:23:03 -0500):
[...]
> >     euronum   \ N N N euron2 | N N euron2 | N euron2
> >     euron2    [{ <.> N N N }] ( <,00> @ | "," NUM NUM )
[...versus...]
> >         euronum   \ N N N euron2 | N N euron2 | N euron2
> >         euron2    [{ <.> N N N }] <,> NUM NUM
> >
> >     And, how does the "corrected" version above fix the problem?
> >
>
> The simpler edit will only work in even pairs so,
>
> 12345,12  will fail but 123456,12 will pass
> Further more, if you tried 1234512 it pairs up
> 123.451 as the digits and pushes 2 as fraction
> thus returning 123.451,20
>
> The right edit makes no assumption to pair up the numbers
> and it "DOES" add ,00 if whole number is entered instead
> of pushing remaining after pairing ...
>
> I think I know what I want to say but as usual, I just do not
> know how.   :-)

Correct.  (Though by "pairs" I assume you mean "sets of three".)


The bad version places no restrictions on where the ",nn" at the end
appears in the incoming data.  So, any time you have 3 or more digits
(and no ","), filePro will take the first three digits, followed by
as many 3-digit sets as are available, add the comma, and then use
up the next up-to-two digits for the cents.

For example, "1234" will be accepted as "123,40", which is obviously
not what you wanted.  ("N N N" accepts the "123", the "<,>" adds the
comma, "NUM" takes the "4", and the second "NUM" adds the zero.)

Only an exact multiple of 3 digits works here.  For example "123456"
will be accepted as "123.456,00".

For similar reasons, numbers with the "," decimal point will fail,
as filePro adds its own comma in the wrong place, and then rejects
the actual comma in the data.


The corrected version fixes this as follows:

    <,00> @

This says "the incoming data must either end in ",00", or we must
already be at the end of the data (without having encountered a ",")
and so the ",00" will be supplied.  If you have no comma, and the
number of digits in the number is not a multiple of 3, the first
part of euronum ("N N N euron2") will fail, and it will try the next
part ("N N euron2") which will succeed with 2+3n digits, and will
fail with 1+3n digits, which will be taken care of by the third part.

If you have a comma, but not followed by "00", the second part will
kick in:

    "," NUM NUM

This forces the comma to already be in the incoming data.  filePro
will not supply any commas here.  Again, the 3n, 2+3n, and 1+3n cases
are handled by the first line of the euronum edit.  Only when you
encounter the incoming comma will the last up-to-2 digits be taken.
Unless you have ore than two digits following the comma (which is
not allowed), all cases with the comma are covered.  And, if you do
have extra digits, they will cause the edit to fail.

--
KenBrody at BestWeb dot net        spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com


More information about the Filepro-list mailing list