Difference between revisions of "MC-Basic:OPEN FILE"
m (added ULB and UPG as optional files to edit) |
|||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Languages|MC-Basic:OPEN_FILE}} | ||
{{MC-Basic | {{MC-Basic | ||
|SHORT FORM= | |SHORT FORM= | ||
Line 14: | Line 15: | ||
Filename should not exceed 8 characters and one of next extensions: | Filename should not exceed 8 characters and one of next extensions: | ||
− | PRG , DAT , TSK , CMP for files ,open at Flash disk | + | PRG , DAT, UPG, ULB, TSK , CMP for files ,open at Flash disk |
or REC, TXT , which open at RAM disk. | or REC, TXT , which open at RAM disk. | ||
Line 20: | Line 21: | ||
Open text file for read, write or append to the existing file according to mode flag. | Open text file for read, write or append to the existing file according to mode flag. | ||
− | + | "r" - open text file for reading | |
− | + | "w" - truncate to zero length or create text file for writing | |
− | + | "a" - append; open or create text file for writing at end-of-file | |
Use APPEND to add new lines at the end of the original contents of the file. | Use APPEND to add new lines at the end of the original contents of the file. | ||
Line 37: | Line 38: | ||
|RANGE= | |RANGE= | ||
''< file name>'': not more, then 12 characters (8 char. name + dot + 3 char. extension) <br> | ''< file name>'': not more, then 12 characters (8 char. name + dot + 3 char. extension) <br> | ||
− | ''<mode flag>'': | + | ''<mode flag>'': "r" – read mode |
− | + | "w" – write mode | |
− | + | "a" - append mode | |
'' <DeviceHandle>'': 1 to 255 | '' <DeviceHandle>'': 1 to 255 | ||
Line 58: | Line 59: | ||
|EXAMPLE= | |EXAMPLE= | ||
− | Open | + | Open "File1.PRG" Mode="w" as #1 |
Or | Or | ||
− | Common shared FileNameStr as string = | + | Common shared FileNameStr as string = "File1.PRG" |
− | Common shared ModeStr as string = | + | Common shared ModeStr as string = "w" |
Open FileNameStr Mode= ModeStr as #1 | Open FileNameStr Mode= ModeStr as #1 | ||
Line 74: | Line 75: | ||
* [[MC-Basic:LOC|LOC]] | * [[MC-Basic:LOC|LOC]] | ||
* [[MC-Basic:PRINT HASH|PRINT HASH]] | * [[MC-Basic:PRINT HASH|PRINT HASH]] | ||
− | * [[ | + | * [[MC-Basic:SEEK|SEEK]] |
− | * [[ | + | * [[MC-Basic:TELL|TELL]] |
− | [[Category | + | [[Category:MC-Basic:File Management|OPENFILE]] |
}} | }} |
Latest revision as of 09:19, 7 December 2022
Language: | English • 中文(简体) |
---|
Opens an existing file or creates new one (in “write” mode) with the name given in the string expression.
Filename should not exceed 8 characters and one of next extensions:
PRG , DAT, UPG, ULB, TSK , CMP for files ,open at Flash disk
or REC, TXT , which open at RAM disk.
Open text file for read, write or append to the existing file according to mode flag.
"r" - open text file for reading
"w" - truncate to zero length or create text file for writing
"a" - append; open or create text file for writing at end-of-file
Use APPEND to add new lines at the end of the original contents of the file.
Use WRITE to overwrite the previous file or for the new one creation .
Syntax
Open<file name> MODE= <mode flag> As #<DeviceHandle>
Availability
Versions 0.3.6.14 and higher
Type
< file name>: String
<mode flag>: String
<DeviceHandle>: Long
Range
< file name>: not more, then 12 characters (8 char. name + dot + 3 char. extension)
<mode flag>: "r" – read mode
"w" – write mode
"a" - append mode
<DeviceHandle>: 1 to 255
Scope
Task or Terminal
Limitations
The defined file should exist on DiskOnChip for read and append modes
Examples
Open "File1.PRG" Mode="w" as #1
Or
Common shared FileNameStr as string = "File1.PRG"
Common shared ModeStr as string = "w"
Open FileNameStr Mode= ModeStr as #1