Here's a function I use regularly:

/* Function NormaliseSpace ( string; noParas )
Cleans up a text field by reducing all multiple spaces and returns; if
noParas is true removes all returns (converts them to spaces). Makes
use of TrimAll function, and temporarily changes returns to spaces to
reduce them.
Gotcha: relies on temp string not being used within the field.
string = string to clean up
noParas = boolean; flags if Returns to be removed (otherwise they're reduced)
*/

If ( noParas;
        TrimAll ( Substitute ( string; "¶"; " "); False; 2 ); // use FM
function to strip all returns
// else
        Substitute (
                TrimAll ( // reduces all returns after they've been converted 
to spaces
                        Substitute ( TrimAll ( string; False; 2 ); // reduces 
spaces
                                [" ¶"; "¶"];
                                ["¶ "; "¶"];
                                [" "; "�...@§"]; // temporarily "saves" 
spaces...
                                ["¶"; " "] ); // and change return to space
                        True; 1 );
                [" " ; "¶"]; // restore returns
                ["�...@§" ; " "] ) // restores "real" spaces
)



-- 
Tim Mansour <[email protected]>
Neologica Print & Promotions (ABN 63 904 335 408)
159 Commonwealth Street : Surry Hills NSW 2010 : Australia
Mobile 0405 500 846 : Sydney 02 9043 3223 : Melbourne 03 9012 7441

Reply via email to