<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.ice-online.com/index.php?action=history&amp;feed=atom&amp;title=FILE</id>
	<title>FILE - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ice-online.com/index.php?action=history&amp;feed=atom&amp;title=FILE"/>
	<link rel="alternate" type="text/html" href="https://wiki.ice-online.com/index.php?title=FILE&amp;action=history"/>
	<updated>2026-04-13T10:32:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.ice-online.com/index.php?title=FILE&amp;diff=777&amp;oldid=prev</id>
		<title>ConvertBot: Macro interface to Midas data(*.tmp,*.prm), text or other files</title>
		<link rel="alternate" type="text/html" href="https://wiki.ice-online.com/index.php?title=FILE&amp;diff=777&amp;oldid=prev"/>
		<updated>2020-04-27T22:04:53Z</updated>

		<summary type="html">&lt;p&gt;Macro interface to Midas data(*.tmp,*.prm), text or other files&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Macro interface to Midas data(*.tmp,*.prm), text or other files&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;FUNC&amp;gt;   Function to perform:  CLOSE, COPY, DETACH, EDIT, NAME, NEXT, OPEN,&lt;br /&gt;
           PROTECT, READ, RENAME, SAVE, UNPROTECT, VIEW, WRITE&lt;br /&gt;
&amp;lt;LABEL&amp;gt;  Label of results parameter that will reference Text or Data File object&lt;br /&gt;
&amp;lt;P1&amp;gt;     First &amp;lt;FUNC&amp;gt;-dependent parameter&lt;br /&gt;
&amp;lt;P2&amp;gt;     Second &amp;lt;FUNC&amp;gt;-dependent parameter&lt;br /&gt;
&amp;lt;P3&amp;gt;     Third &amp;lt;FUNC&amp;gt;-dependent parameter&lt;br /&gt;
&lt;br /&gt;
Enables a macro command to perform I/O with a Midas text or data file. If the&lt;br /&gt;
end-of-file is encountered during READ and DEBUG ON IO is applied, a WARNING&lt;br /&gt;
will be issued.&lt;br /&gt;
&lt;br /&gt;
NeXtMidas supports a number of file types, not just Midas Blue files.  A partial&lt;br /&gt;
list of supported files includes:&lt;br /&gt;
&lt;br /&gt;
  File Type                      Extension(s)   Supporting Class&lt;br /&gt;
  ------------------------------ ------------   ----------------&lt;br /&gt;
  * Midas Blue                   tmp, prm       nxm.sys.lib.DataFile&lt;br /&gt;
  * Text                         txt            nxm.sys.lib.TextFile&lt;br /&gt;
  * Comma-Separated-Value (CSV)  csv            nxm.sys.lib.CsvFile&lt;br /&gt;
  * Audio                        wav            nxm.sys.lib.DataFile&lt;br /&gt;
  * Image                        jpeg,jpg,gif,  nxm.sys.lib.ImageFile&lt;br /&gt;
                                 bmp,wbmp,png&lt;br /&gt;
  * Shapefile                    shp            nxm.sys.lib.ShapeFile&lt;br /&gt;
                                 dbf            nxm.sys.lib.DbfFile&lt;br /&gt;
  * Zip                          zip            nxm.sys.lib.ZipFile&lt;br /&gt;
&lt;br /&gt;
  * Multi-Resolution Seamless    sid            nxm.map.lib.MrSidFile&lt;br /&gt;
    Image Database (MrSid)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For a complete list of file extensions mapped to Java supporting class, type&lt;br /&gt;
  nM&amp;gt; res reg.handlers.file&lt;br /&gt;
&lt;br /&gt;
Functions:&lt;br /&gt;
  CLOSE - FILE CLOSE &amp;lt;LABEL&amp;gt;&lt;br /&gt;
    Close the file referenced by &amp;lt;LABEL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  COPY - FILE COPY &amp;lt;LABEL&amp;gt; &amp;lt;P1=target file&amp;gt;&lt;br /&gt;
    Copy a generic, unopened file named &amp;lt;LABEL&amp;gt; to &amp;lt;target file&amp;gt;. This performs&lt;br /&gt;
    a BINARY copy of the file.&lt;br /&gt;
&lt;br /&gt;
    One or more of the following modifiers can be attached to the COPY function:&lt;br /&gt;
      /F - Overwrite target file if it exists&lt;br /&gt;
      /M - Make directories as required if they do not exist&lt;br /&gt;
&lt;br /&gt;
    The output &amp;lt;target&amp;gt; file's size is pre-allocated to the input file's size&lt;br /&gt;
    on disk (since NextMidas 3.1.2). This can be disabled via the&lt;br /&gt;
    {PREALLOCATELENGTH=false} file qualifier on the output file name.&lt;br /&gt;
&lt;br /&gt;
  COPY/L - FILE COPY &amp;lt;LABEL&amp;gt; &amp;lt;P1=target file&amp;gt;            (Since NeXtMidas 2.5.0)&lt;br /&gt;
    Copy a generic, unopened ListFile named &amp;lt;LABEL&amp;gt; to another ListFile named&lt;br /&gt;
    &amp;lt;target file&amp;gt;. This can be used to convert between file types (e.g. CSV to&lt;br /&gt;
    PRM or PRM to CSV) provided that both types implement the ListFile&lt;br /&gt;
    interface.&lt;br /&gt;
&lt;br /&gt;
    One or more of the following modifiers can be attached to the COPY function:&lt;br /&gt;
      /F - Overwrite target file if it exists&lt;br /&gt;
      /M - Make directories as required if they do not exist&lt;br /&gt;
&lt;br /&gt;
    See /PROPAGATE= (since NeXtMidas 2.5.0) and /PROPMASK= (since NeXtMidas&lt;br /&gt;
    3.3.0) for options controlling the propagation of column definitions and/or&lt;br /&gt;
    other header/keyword values.&lt;br /&gt;
&lt;br /&gt;
    Since NeXtMidas 3.3.0 it is possible to include output columns that are&lt;br /&gt;
    automatically computed from the input file. This is done by adding one or&lt;br /&gt;
    more of the following file-qualifiers to the output file:&lt;br /&gt;
      TIME_NAME=[col]  - Name of the column to be populated with the computed&lt;br /&gt;
                         time values. The time value inserted will be a Time&lt;br /&gt;
                         object (which will convert to String/number as needed).&lt;br /&gt;
                         This is only applicable when the input is:&lt;br /&gt;
                           - DataFile (time value taken from df.getTimeAt()), or&lt;br /&gt;
                           - PlotFile with UNITS=TIME_S or UNITS=TIMECODE (value&lt;br /&gt;
                             is computed from pf.getStart() and pf.getDelta())&lt;br /&gt;
&lt;br /&gt;
      ABSC_NAME=[col]  - Name of the column to be populated with the computed&lt;br /&gt;
                         abscissa values. This is only applicable when the input&lt;br /&gt;
                         is:&lt;br /&gt;
                           - DataFile or PlotFile (value is computed from&lt;br /&gt;
                             pf.getStart() and pf.getDelta())&lt;br /&gt;
&lt;br /&gt;
      INDEX_NAME=[col] - Name of the column to be populated with the computed&lt;br /&gt;
                         index value. This applies to all file types and is&lt;br /&gt;
                         automatically computed based on the (zero-based) row&lt;br /&gt;
                         number.&lt;br /&gt;
&lt;br /&gt;
    The primary use of TIME_NAME=, and ABSC_NAME= is in a DataFile to CsvFile&lt;br /&gt;
    conversion where this information would otherwise be lost. If TIME_NAME=&lt;br /&gt;
    or ABSC_NAME= are used in a situation where they are not applicable, the&lt;br /&gt;
    default value for that column (0 or &amp;quot;&amp;quot;) will generally be inserted.&lt;br /&gt;
&lt;br /&gt;
    When using TIME_NAME=, ABSC_NAME= or INDEX_NAME=, if the column identified&lt;br /&gt;
    already exists in the input file, the value from the input file will be&lt;br /&gt;
    ignored in favor of the computed value (where applicable) -- EXCEPT when&lt;br /&gt;
    the column name is given with a &amp;quot;+&amp;quot; prefix (e.g. TIME_NAME=+TIME) in which&lt;br /&gt;
    case the value from the input file will be kept.&lt;br /&gt;
&lt;br /&gt;
  DETACH - FILE DETACH &amp;lt;LABEL=file&amp;gt; &amp;lt;P1=data_file_ext DEF=det&amp;gt;     (Since 2.9.1)&lt;br /&gt;
    Rename &amp;lt;LABEL=file&amp;gt; to &amp;lt;file's_basename&amp;gt;.&amp;lt;data_file_ext&amp;gt; (if it exists and&lt;br /&gt;
    contains an attached header) and create a new detached header (BLUE) file.&lt;br /&gt;
    The header is created on the same AUX as the original file and the data&lt;br /&gt;
    offset is set such that the data portion of the input file is not disturbed&lt;br /&gt;
    (i.e. the original file is not modified it will still contain an unused&lt;br /&gt;
    header which is ignored by all Midas commands). This is the same as&lt;br /&gt;
    &amp;quot;DETACH &amp;lt;file&amp;gt;&amp;quot; in X-Midas. For Example:&lt;br /&gt;
&lt;br /&gt;
    One or more of the following modifiers can be attached to the this function:&lt;br /&gt;
      /F - Overwrite target file if it exists&lt;br /&gt;
      /D - Split the &amp;lt;LABEL=file&amp;gt; into a header-only detached header (BLUE) file&lt;br /&gt;
           and copy the data section into a data-only file&lt;br /&gt;
           &amp;lt;file_basename&amp;gt;.&amp;lt;data_file_ext&amp;gt; (starting at offset 0). This similar&lt;br /&gt;
           to using &amp;quot;NOOP origfile newfile{det=data_file_ext}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    nM&amp;gt; file detach   testfile.tmp&lt;br /&gt;
    nM&amp;gt; file detach/d testfile2.tmp raw&lt;br /&gt;
&lt;br /&gt;
  EDIT - FILE EDIT &amp;lt;LABEL&amp;gt;&lt;br /&gt;
    Edit the opened .txt, .html, or .rtf file referenced by &amp;lt;LABEL&amp;gt;.&lt;br /&gt;
    (reserved for future implementation)&lt;br /&gt;
&lt;br /&gt;
  NAME - FILE NAME &amp;lt;LABEL&amp;gt; &amp;lt;P1=pathlist&amp;gt; &amp;lt;P2=root name&amp;gt; &amp;lt;P3=extension&amp;gt;&lt;br /&gt;
    Form a name in a system independent manner from &amp;lt;pathlist&amp;gt;, &amp;lt;root name&amp;gt;,&lt;br /&gt;
    and &amp;lt;extension&amp;gt;, storing the assembled name into the results parameter named&lt;br /&gt;
    &amp;lt;LABEL&amp;gt;.  The &amp;lt;pathlist&amp;gt; parameter must be in the form (top,next,lower,...)&lt;br /&gt;
    as shown in the example below. NOTE: On Windows, you cannot specify a&lt;br /&gt;
    mapped drive in your path; you must use the full path. See AUXILIARY.&lt;br /&gt;
&lt;br /&gt;
  NEXT - FILE NEXT &amp;lt;LABEL&amp;gt; &amp;lt;P1=string&amp;gt;&lt;br /&gt;
    Read the next valid line from the opened file referenced by &amp;lt;LABEL&amp;gt; into the&lt;br /&gt;
    results parameter named &amp;lt;string&amp;gt;.  This command interprets continuation&lt;br /&gt;
    characters and comment characters as they are in macros, .KEY files, and&lt;br /&gt;
    other Midas text files.  If an end-of-file or file error occurs, &amp;lt;string&amp;gt;&lt;br /&gt;
    receives the value &amp;quot;NULL&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
  OPEN - FILE OPEN &amp;lt;LABEL&amp;gt; &amp;lt;P1=filename&amp;gt;&lt;br /&gt;
    Open a file named &amp;lt;filename&amp;gt; and store a reference to resulting TextFile,&lt;br /&gt;
    DataFile or BaseFile object in the results parameter named &amp;lt;LABEL&amp;gt;. The&lt;br /&gt;
    following switches can be attached to the OPEN parameter:&lt;br /&gt;
&lt;br /&gt;
      File Type: (default based on file extension)&lt;br /&gt;
        /D   - Treat the file as a DataFile (Midas Blue File)&lt;br /&gt;
        /T   - Treat the file as a TextFile (can not be combined with /D)&lt;br /&gt;
&lt;br /&gt;
      In/Out Mode: (default is INPUT)&lt;br /&gt;
        /A   - APPEND to an existing file&lt;br /&gt;
        /N   - Create a NEW file for OUTPUT&lt;br /&gt;
        /W   - Open an existing file for INPUT/OUTPUT (this keeps file header&lt;br /&gt;
               but does not advance write pointer to the end of the file - in&lt;br /&gt;
               most cases /A is what you want, not /W)&lt;br /&gt;
&lt;br /&gt;
    If neither /T or /D is specified, the type is determined from the extension&lt;br /&gt;
    or the {FG=x} qualifier and handled by the class named in REG.FILE.HANDLERS.&lt;br /&gt;
&lt;br /&gt;
    To apply other flags when opening the file use the FLAGS=&amp;quot;&amp;quot; qualifier with&lt;br /&gt;
    the flag names (Input|Output|Wrap|Append|Flush|NoAbort|Optional|Native):&lt;br /&gt;
      nM&amp;gt; file open/t tag temp.txt{flags=&amp;quot;APPEND|FLUSH&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
    Once the file is open it is possible to find out what methods are available&lt;br /&gt;
    using:&lt;br /&gt;
      nM&amp;gt; query &amp;lt;LABEL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    ** Note: In NeXtMidas 2.4.0 TextFile assumes that {FLAGS=NOABORT} is always&lt;br /&gt;
             set. Since 2.5.0 this behavior is deprecated and NOABORT will only&lt;br /&gt;
             be used when explicitly set. To disable the deprecation warnings,&lt;br /&gt;
             set {FLAGS=NOABORT} or {FLAGS=FORCEABORT} when opening a TextFile.&lt;br /&gt;
&lt;br /&gt;
  PROTECT -  FILE PROTECT &amp;lt;P1=filename&amp;gt;&lt;br /&gt;
    Sets the protected flag in the header of a DataFile (.tmp or .prm) to true.&lt;br /&gt;
&lt;br /&gt;
  READ - FILE READ &amp;lt;LABEL&amp;gt; &amp;lt;P1=element&amp;gt;&lt;br /&gt;
    Read the next element from the opened file referenced by &amp;lt;LABEL&amp;gt; into the&lt;br /&gt;
    results parameter named &amp;lt;element&amp;gt;.  If an end-of-file or file error occurs,&lt;br /&gt;
    &amp;lt;element&amp;gt; receives the value &amp;quot;NULL&amp;quot; (when &amp;lt;LABEL&amp;gt; references a TextFile&lt;br /&gt;
    object).&lt;br /&gt;
&lt;br /&gt;
    Note: Prior to NeXtMidas 3.3.0, calls to READ that were at end-of-file&lt;br /&gt;
          erroneously returned a data buffer (with junk data) in cases where&lt;br /&gt;
          &amp;lt;LABEL&amp;gt; pointed to a DataFile.&lt;br /&gt;
&lt;br /&gt;
  RENAME -  FILE RENAME &amp;lt;LABEL&amp;gt; &amp;lt;P1&amp;gt;&lt;br /&gt;
    Rename the unopened file named &amp;lt;LABEL&amp;gt; to &amp;lt;P1&amp;gt;  One or more of the following&lt;br /&gt;
    switches can be attached to the RENAME parameter:&lt;br /&gt;
      /F - Overwrite target file if it exists&lt;br /&gt;
&lt;br /&gt;
  SAVE -  FILE SAVE &amp;lt;LABEL&amp;gt;&lt;br /&gt;
    Save the unopened file named &amp;lt;LABEL&amp;gt; by changing its extension to .prm&lt;br /&gt;
&lt;br /&gt;
  UNPROTECT -  FILE UNPROTECT &amp;lt;P1=filename&amp;gt;&lt;br /&gt;
    Sets the protected flag in the header of a DataFile (.tmp or .prm) to false.&lt;br /&gt;
&lt;br /&gt;
  VIEW - FILE VIEW &amp;lt;LABEL&amp;gt;&lt;br /&gt;
    View the opened .txt, .html, or .rtf file referenced by &amp;lt;LABEL&amp;gt;.&lt;br /&gt;
    (reserved for future implementation)&lt;br /&gt;
&lt;br /&gt;
  WRITE - FILE WRITE &amp;lt;LABEL&amp;gt; &amp;lt;P1=data&amp;gt;&lt;br /&gt;
    Append &amp;lt;data&amp;gt; to the end of the opened file referenced by &amp;lt;LABEL&amp;gt;&lt;br /&gt;
    (data is String when &amp;lt;LABEL&amp;gt; references a TextFile object)&lt;br /&gt;
    (data is Data/Table when &amp;lt;LABEL&amp;gt; references a DataFile object)&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
 1. Define the structure and open a new type 3000 file for writing, write one&lt;br /&gt;
    element, and then close the file&lt;br /&gt;
      nM&amp;gt; file open/d/n tag temp{sr=(LAT/SD,LON/SD)}&lt;br /&gt;
      nM&amp;gt; res tag.setdata(0,&amp;quot;LAT&amp;quot;) 77.7&lt;br /&gt;
      nM&amp;gt; res tag.setdata(0,&amp;quot;LON&amp;quot;) 99.9&lt;br /&gt;
      nM&amp;gt; file close tag&lt;br /&gt;
    Note: the quotation of record names inside the method signature is HIGHLY&lt;br /&gt;
          RECOMMENDED.&lt;br /&gt;
&lt;br /&gt;
 2. Open a file for reading and writing with its existing structure intact&lt;br /&gt;
    (assumes file exists)&lt;br /&gt;
      nM&amp;gt; file open/d/w tag temp&lt;br /&gt;
      nM&amp;gt; res tag.getdata(0,LAT)&lt;br /&gt;
      D: TAG.GETDATA(0,LAT) = 77.7&lt;br /&gt;
&lt;br /&gt;
 3. Load a row of data from the type 3000 file into a table&lt;br /&gt;
      nM&amp;gt; file open/d tag temp&lt;br /&gt;
      nM&amp;gt; res tab tag.getDataTable(0)&lt;br /&gt;
      nM&amp;gt; res tab&lt;br /&gt;
      T: TAB             = Table of 2 entries&lt;br /&gt;
      D:  LAT            = 77.7&lt;br /&gt;
      D:  LON            = 99.9&lt;br /&gt;
&lt;br /&gt;
    NOTE: To read through and process an entire file from the macro language,&lt;br /&gt;
          see FOREACH.&lt;br /&gt;
&lt;br /&gt;
 4. Form a full file name on a UNIX system&lt;br /&gt;
      nM&amp;gt; file NAME fullname (home,user,temp) myfile ext&lt;br /&gt;
      nM&amp;gt; res fullname&lt;br /&gt;
      26S: FULLNAME        = /home/user/temp/myfile.ext&lt;br /&gt;
&lt;br /&gt;
 5. Convert a comma-separated value (CSV) text file into a table&lt;br /&gt;
      nM&amp;gt; file open filetag nxm.sys.dat.airports.csv{HEADERROWS=1}&lt;br /&gt;
      nM&amp;gt; res t:tbl filetag.toTable(ROW_)&lt;br /&gt;
      nM&amp;gt; file close filetag&lt;br /&gt;
&lt;br /&gt;
 6. Protect or unprotect a file&lt;br /&gt;
      nM&amp;gt; file protect temp&lt;br /&gt;
      nM&amp;gt; file unprotect temp&lt;br /&gt;
&lt;br /&gt;
 7. Copy a CSV file to a BLUE (.prm) file:&lt;br /&gt;
      nM&amp;gt; file COPY/L test_list2_colors.csv{COLUMNNAMES='ID,COLR'} myfile.prm&lt;br /&gt;
&lt;br /&gt;
 8. Copy a BLUE (.prm) file to a CSV file:&lt;br /&gt;
      nM&amp;gt; file COPY/L testxy3000.prm myfile.csv{HEADERROWS=1}&lt;br /&gt;
&lt;br /&gt;
 9. Copy a BLUE (.prm) file to a CSV file, but copy include the columns&lt;br /&gt;
    named &amp;quot;ABSC&amp;quot; and &amp;quot;ORD&amp;quot; in the new file:&lt;br /&gt;
      nM&amp;gt; file/PROPAGATE=FALSE COPY/L/F &amp;amp;&lt;br /&gt;
                   testxy3000.prm &amp;amp;&lt;br /&gt;
                   myfile.csv{HEADERROWS=1,COLUMNNAMES=&amp;quot;ABSC,ORD&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
 10. Define the structure and open a new complex type 2000 file for&lt;br /&gt;
     writing that has 3 frames; write one frame, and then close the file&lt;br /&gt;
       nM&amp;gt; file open/d/n tag temp{TYPE=2000,FORM=CF,FRAMESIZE=3}&lt;br /&gt;
       nM&amp;gt; file write tag {F1=(1.0,1.0),F2=(2.0,2.0),F3=(3.0,3.0)}&lt;br /&gt;
       nM&amp;gt; file close tag&lt;br /&gt;
&lt;br /&gt;
Switches:&lt;br /&gt;
  /CLEAN           - Cleans the string from a READ or NEXT operation [DEF=FALSE]&lt;br /&gt;
  /PROPAGATE=[T|F] - Used with COPY/L: Propagate column definitions from input&lt;br /&gt;
                     file to output file. [DEF=TRUE]&lt;br /&gt;
  /PROPMASK=[mask] - Used with COPY/L: Mask controlling the propagation file&lt;br /&gt;
                     header values, other than the column definitions (which is&lt;br /&gt;
                     controlled by /PROPAGATE=). This is most frequently used to&lt;br /&gt;
                     propagate the xStart/xDelta values and the keywords&lt;br /&gt;
                     (e.g. /PROPMASK=ALL). Since 3.3.0 [DEF=NONE]&lt;br /&gt;
  /TL=             - Transfer Length (bytes) used with FUNC=COPY [DEF=32768]&lt;br /&gt;
                     Since 3.1.2&lt;br /&gt;
&lt;br /&gt;
See Also:  HEADERMOD, FNAME, FOREACH, ERASE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:NXM_Explain]]&lt;/div&gt;</summary>
		<author><name>ConvertBot</name></author>
		
	</entry>
</feed>