Previous Next        Current Page: NeXtMidas Training / Working with Files / Basic File Commands / FILE - Modifying file data
Start Here   
Background   
Common Midas Concepts   
Getting Started - Part 1   
Getting Started - Part 2   
Working with Files   
   - File Basics   
   + The AUX List   
   - Basic File Commands   
      - FILES - Finding files   
      - FNAME - Forming file names   
      - STATUS - Listing file headers   
      - DATALIST - Listing file data   
      - HEADERMOD - Modifying file headers   
      - FILE - Modifying file data   
   + Lab 1   
   + File Names   
   + File Types   
   + Lab 2   
   + Listing Files   
   + Lab 3   
   + Plotting Files   
   + Lab 4   
Option Trees   
Macros - Part 1 (Basics)   
Macros - Part 2 (Graphics)   
NetBeans - Part 1 (Setup)   
NetBeans - Part 2 (GUIs)   
NetBeans - Part 3 (Profiler)   
Eclipse - Part 1 (Setup)   
Eclipse - Part 2 (GUIs)   
Primitives   
Applets & WebStart   
Maps & Imagery   
X-Midas Interoperability   
RMIF & Remoting   
Installing NeXtMidas   
Support & Maintenance   
File Handlers   


  • The FILE Command:
    • The FILE command is used to perform I/O on a file from a macro.
      nM> FILE <func> <label> ...
    • The FILE command can manipulate any of the file types for which there is a file handler, not just Midas Blue files.
      • NeXtMidas automatically selects the appropriate file handler to use; however, there are options that allow this to be overridden.
        nM> file open tag airports.csv{headerrows=1}
        nM> invoke ,, tag.getDataTable(42)
        Invoke: ANSWER = {AIRPORT_NAME="Avalon",CODE="AVL",
                          LATITUDE="-038.04083",LONGITUDE="144.46806"}
        nM> file close tag
        (Note that tag can be any results parameter name, this is just a simple example.)
    • A typical usage is to OPEN the file, READ from it or WRITE to it, then close it. (OPEN/N can be used to create a new file.)
      nM> file open/d/n tag my_really_long_file_name{sr=(LAT/SD,LON/SD)}
      nM> res tag.data(0,"LAT") 77.7
      nM> res tag.data(0,"LON") 99.9
      nM> file close tag
    • In between the OPEN and CLOSE, the file is in memory and can be altered quickly.
      • While in memory, a file can is referenced by the provided <LABEL>.
    • The FILE command has many other functions not outlined here (COPY, DETACH, NAME, RENAME, PROTECT, SAVE, etc.). See the explain file for FILE for details.
X-Midas Users Take Note:
The PROTECT and UNPROTECT functions in FILE are used in place of the X-Midas PROTECT and UNPROTECT commands.
The DETACH function in FILE is used in place of the X-Midas DETACH command (since NeXtMidas 2.9.1.)
The OPEN and CLOSE functions work similar to the X-Midas ENV FILE OPEN command.