Brian Dunning's FileMaker Custom Functions

NewlinesToReturns ( text )

In FileMaker 9 and earlier, remove any newline characters (ASCII 10) from the original text, substituting return characters instead.

  Average rating: 4.1 (41 votes) Log in to vote

Debi Fuchs   Debi Fuchs - Show more from this author
Aptworks Consulting
http://www.aptworks.com

Share on Facebook Share on Twitter

  Sample input:
NewlinesToReturns ( Contacts::Notes )
  Sample output:
[contents of Contacts::Notes, with returns in place of any ASCII 10 characters]

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

CUSTOM FUNCTION: NewlinesToReturns ( text )
© 2009 Debi Fuchs of Aptworks Consulting, debi@aptworks.com

In FileMaker 9 and earlier, remove any newline characters (ASCII 10) from the original text, substituting return characters instead.

This is useful because newlines are hard to remove prior to FileMaker 10, because of the lack of the "Char" function in those versions, and because newlines can not be pasted into the calculation dialog box. Starting with FileMaker 10 (thanks for the tip from "VR" on the custom functions forum at briandunning.com) use this:

Substitute(text; Char(10); ¶)

EXAMPLES:
NewlinesToReturns( myTable::myField )

IMPLEMENTATION: This function takes advantage of the fact that Value functions treat newlines like returns

NOTES: Tested on Mac only, so far.

LAST MODIFIED: 13-JUL-2009 by Debi Fuchs of Aptworks Consulting

 

Comments

comment   comment, VR
Jul 12, 2009
How about:

Substitute ( text ; Char(10) ; ¶ )
 
DF   DF, Boston, MA
Jul 13, 2009
Thanks, VR. You're right (starting with FileMaker 10). I'll add that in.
 
comment   comment, VR
Jul 13, 2009
Here's an alternative that should work with any version from 8 and higher:

Let ( [
xCR = Substitute ( text ; ¶ ; "" ) ;
LF = Middle ( xCR ; Length ( GetValue ( xCR ; 1 ) ) + 1 ; 1 )
] ;
Substitute ( text ; LF ; ¶ )
)


The name is "comment", BTW - see:
http://www.briandunning.com/filemaker-custom-functions/results.php?keyword=comment
 
DF   DF, Boston, MA
Jul 15, 2009
Doh! Can I put your code in there, instead, giving you all credit of course? Alternately, I can ask Brian to delete it and you can put it yourself. Either way is fine by me: I think this is a useful custom function for people and it should be accessible.
 
comment   comment, VR
Jul 15, 2009
Whatever you prefer is fine by me.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: