1 Reply Latest reply on Dec 20, 2009 8:18 AM by FentonJones

    Read from txt-file



      Read from txt-file




      I am a newbie to FileMaker and so far I did not succeed in reading a numeric value from a txt-file and putting this value into a global variable. Is that possible in FileMaker? If not - how can I put a value into a global variable?




        • 1. Re: Read from txt-file

          It is a little difficult to answer, as we don't really know the specifics. Is the numeric value the ONLY thing in the text file? (likely not). If not, are values on separate lines?


          FileMaker can use Import Folder, [x] Text files, to import all the lines of a text file into one field. Then you could parse out the one you want. But that implies there's only 1 file in the folder, or that you want to import several files at once. 


          It can also just Import a text file. But that is going to import each line into a new record, and any comma-separated or tab-separated text (whichever you choose as the type) into separate fields.


          Which platform does this need to work on? Mac? Windows? Both?


          On a Mac you can easily "read" a text file using AppleScript. I image Windows has something similar. Or you can use a free plug-in, for cross-platform compatibility. ScriptMaster, from 360Works can read a text file. It is one of the examples in the FileMaker file which comes with it.


          As far as a "global variable", I think you'd have to set a global field, at least first. Neither Import, nor any external tool can set a FileMaker script Variable (if that is what you mean by global variable). But a global field would work much the same. 


          In either case, global variables (or fields) need to be cleared either before use, or after, or both, depending on the circumstances. So there is not a value there when there should not be. This is especially true with global fields on non-hosted files.