Browse code

Added simple File/save example

Andrew Alderwick authored on 21/05/2021 13:10:57
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,38 @@
1
+( simple Dev/File writing example )
2
+
3
+( devices )
4
+
5
+|00 @System     [ &vector $2 &pad    $6 &r      $2 &g     $2 &b      $2 ]
6
+|a0 @File       [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
7
+
8
+( variables )
9
+
10
+|0000
11
+
12
+( init )
13
+
14
+|0100 @reset ( -> )
15
+
16
+	( save contents to file )
17
+	;contents/end ;contents SUB2 .File/length DEO2
18
+	;filename .File/name DEO2
19
+	;contents .File/save DEO2
20
+
21
+	.File/success DEI2 ORA ,&success JCN
22
+	( failed to write: bright yellow background )
23
+	#f0f7 .System/r DEO2
24
+	#f0f7 .System/g DEO2
25
+	#00f7 .System/b DEO2
26
+	BRK
27
+
28
+	&success
29
+	( write successful: dark blue background )
30
+	#00f7 .System/r DEO2
31
+	#00f7 .System/g DEO2
32
+	#40f7 .System/b DEO2
33
+	BRK
34
+
35
+@filename "hello.txt 00
36
+@contents "Hello 20 "world, 20 "how 20 "are 20 "you? 0a
37
+	&end
38
+