Current Page:
NeXtMidas Training
Working with Files
Basic File Commands
FILE - Modifying file data
|
|
- 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 fileTag airports.csv{headerrows=1}
nM> invoke ,, fileTag.getDataTable(42)
Invoke: ANSWER = {AIRPORT_NAME="Avalon",CODE="AVL",
LATITUDE="-038.04083",LONGITUDE="144.46806"}
nM> file close fileTag
(Note that fileTag 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 fileTag my_really_long_file_name{sr=(LAT/SD,LON/SD)}
nM> res fileTag.data(0,"LAT") 77.7
nM> res fileTag.data(0,"LON") 99.9
nM> file close fileTag
- 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.
|
|
|
|