MIAMEX 181: Get / Set CSV Delimiter

Added May 2010

xcall MIAMEX, MX_CSVDELIM, opcode, delim

MX_CSVDELIM allows the CSV delimiter to be set or retrieved.

Parameters

opcode  (Num)  [in]

0 to retrieve, 1 to set

delim  (String, 1)  [in/out]

the delimiter retrieved (opcode 0) or to be set (opcode 1)

When set, the specified delimiter overrides the one normally used by the WRITECD, WRITETD, and INPUT CSV statements.

The setting persists for the remainder of the session, or until changed explicitly by another call to MX_CSVDELIM.

To restore the default behavior, in which the delimiter is determined by the most prevalent of the four typical delimiter characters—comma, semicolon, colon, and tab—in the first line of the file, set the delim to "" (null).

Example

XCALL MIAMEX, MX_CSVDELIM, 0, OLD'DELIMITER$        ! retrieve original

XCALL MIAMEX, MX_CSVDELIM, 1, NEW'DELIMITER$        ! set new

OPEN #CH, FILE$, INPUT

 

XCALL MIAMEX, MX_CSVDELIM, 1, OLD'DELIMITER$        ! reset to original delimiter (won't affect this file)

 

INPUT CSV #CH, VAR1, VAR2, ...                      ! (uses NEW'DELIMITER$)

 

History

2011 May, A-Shell 5.1.215:  Routine added to A-Shell