$FILEOPEN (open file)
$FILEOPEN declares the start of editing of a file to which data is to be output.
Syntax
file-object=$FILEOPEN(file-name,mode)
Values
-
file-object
Specifies the name of the variable into which the acquired file on which editing is to begin is set.
-
file-name
Specifies a file name, either as a constant or a variable. A constant must be enclosed in single quotation marks ('').
Specify the file name with a relative path referenced to the base path specified with the -bp option of the jamscript command. If the -bp option was omitted, Asset-Console-installation-folder\scriptwork is assumed to be the reference folder.
-
mode
Specifies one of the following modes as the editing method:
-
NEW: Create as a new file. Do not specify this mode for existing files.
-
RENEW: Overwrite an existing file. A new file is created if there is no existing file.
-
ADD: Append to an existing file. Do not specify this mode for new files.
-
Status
The following table lists and describes the possible statuses:
Status |
Description |
---|---|
NORMAL |
Normal end |
NODATA |
— |
ERROR |
— |
Script execution interrupted |
Indicates one of the following:
|
Example
The following example creates the file output.csv, and outputs to that file "Asset ID","Asset No","Asset status","Asset type":
[SET_VALUE] FH = $FILEOPEN('output.csv', RENEW) $SETARRAY(OUTLINE,'Asset ID') $SETARRAY(OUTLINE,'Asset No') $SETARRAY(OUTLINE,'Asset status') $SETARRAY(OUTLINE,'Asset type') $FILEARRAY(FH, OUTLINE) $CLEARARRAY(OUTLINE) $FILECLOSE(FH)
- Execution result:
-
The following is output to output.csv:
"Asset ID","Asset No.","Asset status","Asset type"