OPEN


 [Features] To establish input/output, and to open file.

 [Format] OPEN "filename" [FOR "mode"] AS [#]n

 [Explanation]
    The location without access permission can't be accessed.
    mode (capital ok)
    -sequential file
      'input'  text input mode.
      'output'  text output mode.
      'append'  text output append mode.
    -random file
      'binary'  1byte read/write mode.
      When omitting description of [FOR "mode"], it become 'binary' mode.
      When specified file already exists, it'll be R/W mode after reading the data.
    #n
    A file number is assigned.
    This file number can open 15 files from 1 to 15,
    'output''append' and 'input', these can open only one respectively.
    (Randomfile'binary' can open plurality)
    The "filename" must have an extension.
    A location without access right is not accessible.
    c.f. [About text data delimiter of file input/output]
         item: FileAccess below.

 [e.g.] The example of file access.
   [smp_file.bas]
    100 open "file1.txt" for output as #1
    110 print #1,"File access."
    120 close #1
    130 open "file1.txt" for input as #2
    140 line input #2,a$
    150 close #2
    160 print a$
    170 open "file2.dat" for binary as #1
    180 put #1,,65
    190 close #1
    200 open "file2.dat" for binary as #2
    210 get #2,,d
    220 close #2
    230 print d



  CLOSE


 [Features] To close the file.

 [Format] CLOSE [[#]n][,[#]n]...

 [Explanation]
    #n: FileNumber
    When there is no specification of a number, all the files are closed.


  PRINT#


 [Features] To write data to a sequential text file.

 [Format] PRINT #n,data[|,or;|data]...

 [Explanation]
    #n: FileNumber Type:"output"or"append"
    Data is a numerical value type and a character type.
    It specify the file number opened by 'open' command.
    When the sentence end is ';', line feed code isn't outputted.
    c.f. [About text data delimiter of file input/output]
         item: FileAccess below.


  PRINT# USING


 [Features] Data is outputted to the file according to "Format-control-string".

 [Format] PRINT #n,USING "Format-control-string"; data[|,or;|data]...

 [Explanation]
    #n: FileNumber  Type:"output"or"append"
    Refer to the 'PRINT USING' command
     for the specification method of "Format-control-string".
    When the sentence end is ';', line feed code isn't outputted.

 [e.g.]
    print #1,using "P=###.## @"; 12.345,"Board"



  WRITE#


 [Features] To write data to a sequential text file.

 [Format] WRITE #n,data[|,or;|data]...

 [Explanation]
    #n: FileNumber  Type:"output"or"append"
    There is no useless blank output by pause.
    A character string is enclosed and outputted by double quotes"".
    c.f. [About text data delimiter of file input/output]
         item: FileAccess below.


  INPUT#


 [Features] To read data from a sequential text file and substitute them to 'variable'.

 [Format] INPUT #n,variable[$]

 [Explanation]
    #n: FileNumber  Type:"input"
    The type of a variable and data needs to correspond.
    c.f. [About text data delimiter of file input/output]
         item: FileAccess below.


  LINE INPUT#


 [Features] To read data from a sequential text file and substitute them to 'CharValue$'.

 [Format] LINE INPUT #n,CharValue$

 [Explanation]
    #n: FileNumber  Type:"input"
    It treat a comma as a series of letters not a pause.
    c.f. [About text data delimiter of file input/output]
         item: FileAccess below.


  GET


 [Features] To get 1byte data from a random file and substitute them to 'variable'.

 [Format] GET #n,[pos],variable

 [Explanation]
    #n: FileNumber  Type:"read"
    pos: The position of a random file.


  PUT


 [Features] To write 1byte data to a random file.

 [Format] PUT #n,[pos],data

 [Explanation]
    #n: FileNumber Type:"write"
    pos: The position of a random file.
    When specified position is over the size of the existing file,
     the size is expanded automatically.


  EOF


 [Features] If the file specified by 'n' have reached the end of the file, return true(-1).

 [Format] EOF(n)

 [Explanation]
    n : File number.




  About text data delimiter of file input/output.

  print#,write#,input#,line-input#: The respective difference and usage.

  Text file output/input are as follows: print#,(line)input#
   print #1,"data1"
   input #2,a$

  To complement the details about delimitation
   when exchanging multiple data in a statement.
  The specification have the same compatibility with the conventional 'Basic'.
  Since it is a little complicated, so it's explained about the details.

  The delimiter of multiple data
  In case of numerical data:
  Comma[,] Enter[ret] and Space[ ] are identified as a delimiter.
  In case of string data:
  Comma[,] Enter[ret] and Double quotation["](back part)
   are identified as a delimiter.
  When a comma follows, it becomes up to the location of a comma.

  The string enclosed by Double quotation, and not one,
   both are available for string data.
  If read the enclosed data, in case of 'input#',
   it become string data excluding double quotation at both edges.
  Ex. [source data] "ab" -> ab [data after acquisition]

  In 'line input#',
  Double quotation, Comma, and Space become also string data as it is.

  Comparison of writing with 'write#'.

  write #1,"ab","cd","ef"
  print #1,"ab","cd","ef"

  In this write-in example, the results read with 'input#'
  In case of 'write#':
  ab
  cd
  ef
  It become 3 data divided by the comma.
  (internal write state: "ab","cd","ef")

  In case of 'print#':
  Comma is regarded to be format of Tab space as well as 'print' statement,
   ab            cd            ef (internal write state is also same as this)
  It become 1 data to be emptied at extra blank.

  For outputting comma as delimitation in 'print#',
   to write the comma as enclosed in double quotation like ",".
  print #1,"ab"+","+"cd"+","+"ef"
  print #1,"ab,cd,ef"
  print #1,"ab";",";"cd";",";"ef"
  These will be the same result - 3 data.

  And when outputting meaningful space at both edges in 'print#',
   to enclose by char-code 'chr$(34)' which mean a double quotation["].
  print #1,chr$(34)+" ab "+chr$(34)
  " ab ": [output result] (["] is excluded when reading)
  print #1," ab "
  ab: [output result]

  These are the cases which wrote data by 'print#',
   when describing by text editor and giving data, like as follows.
  Contents of text file:
  abc (same as: [print #1,"abc"])
  " abc " (same as: [print #1,chr$(34)+" abc "+chr$(34)] or [write #1 " abc "])

  When outputting Comma and Semicolon as a character, enclose it with 'chr$(34)'.
  For example
  print #1," ab , cd "
  This is output as 2 data of [ab, cd] as mentioned above,
  print #1,chr$(34)+" ab , cd "+chr$(34)  -(1)
  In this case, it is treated as 1 string data including the comma as " ab , cd ".

  Note:
  When using binding formula of including the description of 'chr$(34)' like as -(1),
   please execute in c-mode.
  By i-mode, may be unable to distinguish delimitation properly due to multiple["].

  * in 'write#' statement, even if having not to write 'chr$(34)',
   the string are automatically enclosed by "" and output.

  In order to do simple string input/output,
  output: by 'print#', data output one by one.
  input : input with 'line-input#' (divided by comma then 'input#')
  It is general usage.

  And this Basic, regarding the text data to be read,
   it can use not only [made with 'print#'] but [made with Text-editor],
   and [the one acquired by 'inet$()' and saved].
  In reading the text file,
  when linefeed are continuing at the end of file,
  it is deemed that data of 'null+linefeed' is left in 'eof()'.
  Please watch out about the above, and make reading part.