This isn't really a problem with the Code function. I think a more correct description of the issue might be that you can't really paste a carriage return into a calculation definition (including but not limited to the data viewer). What looks like a carriage return actually isn't. This works the same in any calculation or in a script.
A formula like:ValueCount ( "x" & "" & "x" )returns 1.So you need to use the pilcrow:ValueCount ( "x" & "¶" & "x" )
All this just tested on a Mac OS X 10.8.4 with FileMaker Pro Advanced 12.0v3.
You can also insert a return using the list function:
List ( "x" ; "x" )
will also produce the same result. In some calculations, where you need to combine multiple fields in a return separated list and not have an extra return when a field is empty, this method can be a much simpler approach.
Thank you for the post.
By default, in any FileMaker calculation or script dialog window, a return reads as a space and will be ignored. This practice is common to many programming interfaces. Ignoring spaces or returns that are not hard-coded allows the programmer to type code that is more easily read.
The ¶ (Option-7 on Mac OS X) symbol is used in place of the return or enter key. Code ( "¶" ) will return 13. FileMaker will return 32 for a hard coded space (" "), regardless of the keyboard key used to enter the space.