Difference between revisions of "Shell Commands/FileWrite"

From MorphOS Library

< Shell Commands

Line 1: Line 1:
 
'''FileWrite''' - Writes data to a file
 
'''FileWrite''' - Writes data to a file
  
File/A, Size/N/A, Data/N, String, Add/S
+
FILE/A, SIZE/N/A, DATA/N, STRING, ADD/S
 
  <nowiki>
 
  <nowiki>
File   - Filename to write data to
+
FILE   - Filename to write data to
Size   - Amount of data in bytes to be written
+
SIZE   - Amount of data in bytes to be written
Data   - Data to be written in hex
+
DATA   - Data to be written in hex
String - Data in the string format
+
STRING - Data in the string format
Add   - Adds data to an existing file instead of creating a new file
+
ADD   - Adds data to an existing file instead of creating a new file
 
</nowiki>
 
</nowiki>
 
If the length of data is shorter than the size value, the file is filled by repeating the data contents. Strings get separated by null bytes then. Data entered in decimals gets converted to hex. If no data is given, the file is filled with null bytes.
 
If the length of data is shorter than the size value, the file is filled by repeating the data contents. Strings get separated by null bytes then. Data entered in decimals gets converted to hex. If no data is given, the file is filled with null bytes.

Revision as of 13:53, 5 January 2016

FileWrite - Writes data to a file

FILE/A, SIZE/N/A, DATA/N, STRING, ADD/S

FILE   - Filename to write data to
SIZE   - Amount of data in bytes to be written
DATA   - Data to be written in hex
STRING - Data in the string format
ADD    - Adds data to an existing file instead of creating a new file

If the length of data is shorter than the size value, the file is filled by repeating the data contents. Strings get separated by null bytes then. Data entered in decimals gets converted to hex. If no data is given, the file is filled with null bytes.

Examples:

Ram Disk:> FileWrite test 8 0x4d4f5321
Ram Disk:> Type test HEX
0000: 4D4F5321 4D4F5321                   MOS!MOS!

Ram Disk:> FileWrite test 32 STRING MorphOS
Ram Disk:> Type test HEX
0000: 4D6F7270 684F5300 4D6F7270 684F5300 MorphOS.MorphOS.
0010: 4D6F7270 684F5300 4D6F7270 684F5300 MorphOS.MorphOS.

Ram Disk:> FileWrite test 4 STRING MorphOS
Ram Disk:> Type test HEX
0000: 4D6F7270                            Morp

Ram Disk:> FileWrite test 4 STRING MorphOS ADD
Ram Disk:> Type test HEX
0000: 4D6F7270 4D6F7270                   MorpMorp