2021-05-21 13:10:57 +00:00
|
|
|
( simple Dev/File writing example )
|
|
|
|
|
|
|
|
( devices )
|
|
|
|
|
|
|
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
2021-11-06 00:51:43 +00:00
|
|
|
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &load $2 &save $2 ]
|
2021-05-21 13:10:57 +00:00
|
|
|
|
|
|
|
( variables )
|
|
|
|
|
|
|
|
|0000
|
|
|
|
|
|
|
|
( init )
|
|
|
|
|
2021-05-21 13:34:22 +00:00
|
|
|
|0100 ( -> )
|
|
|
|
;try-save JSR2
|
|
|
|
BRK
|
2021-05-21 13:10:57 +00:00
|
|
|
|
2021-05-21 13:34:22 +00:00
|
|
|
@try-save ( -- )
|
2021-05-21 13:10:57 +00:00
|
|
|
( save contents to file )
|
|
|
|
;contents/end ;contents SUB2 .File/length DEO2
|
|
|
|
;filename .File/name DEO2
|
|
|
|
;contents .File/save DEO2
|
|
|
|
|
|
|
|
.File/success DEI2 ORA ,&success JCN
|
|
|
|
( failed to write: bright yellow background )
|
|
|
|
#f0f7 .System/r DEO2
|
|
|
|
#f0f7 .System/g DEO2
|
|
|
|
#00f7 .System/b DEO2
|
2021-05-21 13:34:22 +00:00
|
|
|
JMP2r
|
2021-05-21 13:10:57 +00:00
|
|
|
|
|
|
|
&success
|
|
|
|
( write successful: dark blue background )
|
|
|
|
#00f7 .System/r DEO2
|
|
|
|
#00f7 .System/g DEO2
|
|
|
|
#40f7 .System/b DEO2
|
2021-05-21 13:34:22 +00:00
|
|
|
JMP2r
|
2021-05-21 13:10:57 +00:00
|
|
|
|
|
|
|
@filename "hello.txt 00
|
2021-05-21 13:34:22 +00:00
|
|
|
@contents "Hello 20 "world, 0a "how 20 "are 20 "you? 0a
|
2021-05-21 13:10:57 +00:00
|
|
|
&end
|
|
|
|
|