6 Replies Latest reply on Jun 1, 2014 6:08 PM by taylorsharpe

    Reading a text file as-is into a text field

    scodoc

      I have a device which outputs data through a serial port as text and is captured by an ASCII terminal program. The text may contain multiple LF and not necessarily CRLF pairs, along with a few other ASCII codes (codes below 20h). The pattern of these is important for decoding the data from the text. I want to read a text file into a text field raw without any processing such as converting CRLF pairs into a single CR.

       

      I tried using Scriptworks Read File Contents, but it also pre-processes the text.

       

      Any suggestions how to get a raw text file into a text field?

        • 1. Re: Reading a text file as-is into a text field
          taylorsharpe

          I have used the TROI Serial plugin to read serial devices successfully and it doesn't filter anything out. 

          • 2. Re: Reading a text file as-is into a text field
            taylorsharpe

            Pardon my last post, I was thinking you wanted to read the ASCII terminal data straight into FileMaker, which the TROI serial plugin will do. 

             

            As for reading pre-processed text, you'll find that FileMaker really doesn't do that, but its display does a processing of what it thinkgs you want.  So what you want may really actually be there, just not displayed as you want by FileMaker. 

             

            Do a calculation on the data and do a Substitute ( $Data ; [ Char ( 9 ) ; "[tab]" ] ;  [ Char ( 10 ) ; "[Line Feed]" ] ;  [ Char ( 13 ) ; "[Carriage-Return]" ] ) where $Data is the data or field you are wanting to process. 

             

            This will let you see the tabs, line feeds, and carrier returns. 

            • 3. Re: Reading a text file as-is into a text field
              scodoc

              It is not about re-creating the file, the device is a full-custom piece of research equipment that outputs a variety of data in a haphazard kind-of-disorganized data stream. The data is already captured into a txt file. I just want to read the text file it into a text field in filemaker then have a script tear it apart to find the data we are looking for and then do typical data base stuff on it.

               

              Looks like I am going to have to write a plug-in to do it. Filemaker really irks me at times with the lack of low-level operations to allow experienced programmer to fully control their data flows. Filemaker's assumptions on how to do things are not always optimal or even correct. Unfortunately very few application programs exist that can run on both Mac and Windows which is the only reason I am using filemaker.

              • 4. Re: Reading a text file as-is into a text field
                taylorsharpe

                Yes, serial devices put things out in a stream of data that can seem haphazard, but really does have meaning if you understand how to parse them out.  And you can read that data straight into FileMaker with the TROI serial plugin. 

                 

                You can natively read the txt file with a web portal or Insert from URL and grab the content unchanged.  That is where you run the Substitute I suggested above. 

                 

                You sure seem to want to try to do things the hard way.  You can if you want.  I just don't see why. 

                1 of 1 people found this helpful
                • 5. Re: Reading a text file as-is into a text field
                  scodoc

                  The Insert from URL worked. The text file reads in to the text field without any modifications. Had a problem on the first attempt trying to get the URL format correct. What works is:

                   

                  Insert from URL [Select; No dialog; Text_Table::Raw_Text; "file:///d:/testfiles/test1.txt"]

                   

                  It is those three /// that was the problem. I was using two initially.

                  1 of 1 people found this helpful
                  • 6. Re: Reading a text file as-is into a text field
                    taylorsharpe

                    Yes, figuring out how the OS paths work is always interesting and FileMaker has its way of doing which doesn't always match the native methods, of which most of the plugins use. 

                     

                    But glad to see you have it working and I hope you can parse the data as needed.  Best of luck!