3 Replies Latest reply on Sep 9, 2013 11:27 AM by disabled_ntaylor

    Code function returns incorrect code for a carriage return

    jfletch

      Summary

      Code function returns incorrect code for a carriage return

      Product

      FileMaker Pro

      Version

      11, 12

      Operating system version

      Mac OS X 10.8.4

      Description of the issue

      Manually entering, pasting, or searching for a carriage return into the Code function returns a 32 (space) instead of the expected 13.

      Steps to reproduce the problem

      Open the Data Viewer and hit the watch tab. Create a new item to watch and enter:
      Code ( "
      " )

      will return 32, the ASCII/Unicode decimal for a space.

      Expected result

      13

      Actual result

      32

      Workaround

      None

      Screen_Shot_2013-09-06_at_12.53.30_AM.jpg

        • 1. Re: Code function returns incorrect code for a carriage return
          CamelCase

               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" )

               returns 2.

                

               All this just tested on a Mac OS X 10.8.4 with FileMaker Pro Advanced 12.0v3. 

          • 2. Re: Code function returns incorrect code for a carriage return
            philmodjunk

                 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.

            • 3. Re: Code function returns incorrect code for a carriage return

              Joseph Fletcher:

                   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.

                    

                   TSFalcon
                   FileMaker, Inc.