Possible new function for fp - wishlist item maybe?

Fairlight fairlite at fairlite.com
Mon Jul 10 13:26:14 PDT 2006


This public service announcement was brought to you by GCC Consulting:
> Other then using the mid function to loop through rhe starting name field is
> there another way, using only filepro functions (no outside calls to other
> apps i.e. awk or some other *nix application) to accomplish this easily?
> 
> Would a new function such as aa=xmove(starting field,second field,delimiter)
> be useful?

Borrow existing syntax from perl:

@array = split(DELIMITER,EXPR[,LIMIT])

In perl, delimiter can also be multi-byte, and I'm known to make really
heavy use of that robustness; I think that should be included in fP if the
function is.  While fP is almost certain to not honour regex's like perl's
rendition does, even a baseline hard-value delimiter based split() would do
wonders for fP.

If you wonder what the optional limit does, it says, "Stop after this many
delimiters have been encountered and treat everything after that as one
field."  Example:

"Mary & Mike & John & Bob" will by default be 4 fields with no limit.  If
you specify a limit of 2, you'd get two fields, "Mary", and "Mike & John &
Bob".  That actually has good uses.

I personally think it's a splended candidate for a future addition to fP.
I've wanted this before.  When I was writing the XML parser for OneGate
and wanted to split off the attribute=value pairs for elements comes
specifically to mind...  You just split a string by spaces, then take the
ones with ='s and split them by those.  Voila.  Total PITA to do it the
long way, comparatively.  Obviously possible, just tedious and subject to
far more coding error due to the added complexity.

mark->


More information about the Filepro-list mailing list