4 Replies Latest reply on Jan 26, 2015 5:34 PM by Malcolm

    Managing lists with CR and LF

    Malcolm

      I am wondering about ways to handle lists safely in FileMaker.

       

      It appears as though the default list item separator is char 13, carriage return and that this is true for both Mac and Windows. However, whenever char 10, line feed, is in the text, it is also treated as a list item separator.

       

      If we are building lists, it is possible to make a list in which items are delimited by both char 10 and char 13.

       

      It creates a conundrum. It seems as though it's not possible to determine a single value as the list item separator.  If we have an text string that represents a single value and it contains LF, when it is enters a list the LF becomes a list separator and the value is no longer accessible as a single item.

       

      The solution seems to be to evaluate all text being put into lists. If it contains LF, replace LF with a safe string. If it contains CR, replace CR with a safe string. At the other end, reconstruct the original values by replacing CR and LF.  If you have control of the data at all times then that will work pretty well.  However, if you are unsure about the data, as you substitute the CR/LF back into the text how can you tell whether the list should be delimited by LF or by CR.

        • 1. Re: Managing lists with CR and LF
          wimdecorte

          Malcolm wrote:

           

           

          If we are building lists, it is possible to make a list in which items are delimited by both char 10 and char 13.

           

           

          As long as it stays within FM; why do you want this?  Why not just use what FM uses as the internal list delimiter.

           

          If you get the data from elsewhere it should be easy enough to weed out the char(10) and keep the list FM save.

          • 2. Re: Managing lists with CR and LF
            Malcolm

            I'm writing a custom function that flattens lists to make them safe for passing around via variables. The mechanism uses the list functions, so depends on the data format of the values it receives.

             

            It's an unlikely issue. It's hard to get char(10) into a field without using the functions. I use TextWrangler and have it set to use char(10) as the line delimiter instead of char(13) because I interact with the files on the command line. When I'm cutting and pasting TextWrangler puts everything on the clipboard with char(13). When I'm importing FileMaker handles the line endings properly.

             

            I have been thinking that the CF had a responsibility to preserve the LF and the CR. That's probably right in the small picture, the CF shouldn't have to take responsibility for decisions about line formatting. In the larger picture, we will know whether or not the LF is important and right now I can only think of hypothetical cases when it would be preserved.

             

            In any case, the CF can preserve the LF. It just has to have a few extra lines of code.

            • 3. Re: Managing lists with CR and LF
              jbante

              Other value-delimiter characters to watch out for are the Unicode line separator Char ( 8232 ) and paragraph separator Char ( 8233 ).

              • 4. Re: Managing lists with CR and LF
                Malcolm

                You're right. Both of those can be used to good effect when creating lists. I'll have to remodel my CF to include those two newcomers.

                 

                thanks