string manipulation question

Kenneth Brody kenbrody at bestweb.net
Sat Dec 11 12:10:26 PST 2004


Fairlight wrote:
[...]
> Then your edit solution for Bob, while elegant, would be subject to failure
> if the expansions cause the data to overflow--while a processing-oriented
> soliution would allow the opportunity to trim to the correct length if
> necessary.

True.  You could, of course, make sure that the destination field was
1-1/2 times as long as the source field, to allow for a "worst case"
scenario.

(Question 1.5: Why 1-1/2 times, and not 2 times, when you are replacing
one character with two?  And, in what case[s] would 1-1/2 times be short
by one character, making the answer for those cases "1-1/2 times plus 1"?)

[...]
> Incidentally--the @ in your edit is not officially documented in the
> online help.  I checked a 5.0.6 and a 5.0.10, Tony checked 5.0.14.  The
> -only- place I could find it was on a system that had Laura's help files
> installed.

I'll have to check the official fPTech help files, but the online manual
does list it under "References/Edit/Edits Syntax".

> > Second question to ponder:
> >
> > Given this edit:
> >
> > monexp   monexp1 | monexp2 | monexp3
> > monexp1  "Jan"<uary> | "Feb"<ruary> | "Mar"<ch> | "Apr"<il> | "May" | "Jun"<e>
> > monexp2  "Jul"<y> | "Aug"<ust> | "Sep"<tember> | "Oct"<ober> | "Nov"<ember>
> > monexp3  "Dec"<ember>
> >
> > Why does this not fail, even though we are not stripping trailing spaces?
> 
> Because it never gets past syntax check?  You didn't quote any of the
> "should be there" sections as string literals, so I'm assuming the edit
> editor will puke on this to begin with.  :)
> 
> (SWAG...I think you're trying to trick us!)  :)

Obviously you didn't try it, as there is no syntax error there.  (Check
the global edits table for numerous examples.)

Given a (9,monexp) field, it will successfully convert:

    Jan --> January
    Feb --> February
    Mar --> March

and so on.

So, back to my original "second question to ponder", given the fact that
the first edit will fail without the trailing-space removal, due to the
reason you pointed out:

    Why does this not fail, even though we are not stripping trailing spaces?

-- 
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody        | www.hvcomputer.com |                             |
| kenbrody/at\spamcop.net | www.fptech.com     | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap at gmail.com>



More information about the Filepro-list mailing list