Create a file: Difference between revisions

Added Commodore BASIC
(Added Commodore BASIC)
Line 353:
drwxr-xr-x 2 4096 May 2 23:53 docs
drwxrwxr-x 7 12288 May 2 23:53 .</pre>
 
==={{header|Commodore BASIC}}===
 
On most Commodore 8-bit systems, the most commonly used storage devices were floppy disk drives and cassette tape drives, however these file systems are typically flat (linear) and do not feature any kind of file hierarchy. It is possible that other third-party storage devices (hard drives, etc.) may support such hierarchies, however, the commands to create, delete, and/or navigate in and out of various directories would be unique and specialized to those devices.
 
The example below illustrates the syntax for the open statement which will create the file, however, ''something'' must be written to the file or else nothing will actually be created on the disk. In this case we will simply write a single null byte.
 
Even still, the empty file will still cause Commodore DOS to allocate 1 data block to the file, as reported in a directory listing.
 
<lang gwbasic>
10 rem create a file
20 open 10,8,10,"0:output.txt,seq,write"
30 print#10,chr$(0)
40 close 10
50 rem check device status for error
60 open 15,8,15:input#15,a,b$,c,d:print a;b$;c;d:close 15
</lang>
 
<pre>
RUN
0 OK 0 0
 
READY.
LOAD "$",8
 
SEARCHING FOR $
LOADING
READY.
LIST
 
0 "ROSETTA CODE " RC 2A
1 "OUTPUT.TXT" SEQ
663 BLOCKS FREE.
READY.
</pre>
 
=={{header|Batch File}}==
113

edits