You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _build/reference/599-file-tsave.markdown
+40-10Lines changed: 40 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,11 @@
2
2
3
3
> TSAVE file, var
4
4
5
-
Writes the arrayor string `var` to the text file `file`. Each array element is a text-line in the file. Every line of the string will be one line in the text file. Use `\n` in the string to separate lines.
5
+
Writes array, map or string `var` to the text file `file`. Each array element is a text-line in the file. Every line of the string will be one line in the text file. Use `\n` in the string to separate lines. Maps will be saved as a json string.
6
6
7
7
See TLOAD for loading data from a text-file.
8
8
9
-
### Example 1: Save an array
9
+
### Example 1
10
10
11
11
```
12
12
' Create an array with some data
@@ -24,20 +24,50 @@ tload "myfile.txt", B
24
24
print B ' Output: [1,test,2,]
25
25
```
26
26
27
-
### Example 2: Save a string
27
+
### Example 2: Writing maps as json data
28
28
29
29
```
30
-
' Create a string with some data
31
-
A = "line 1\nline 2\nline 3"
32
-
print A ' Output: line 1
33
-
' line 2
34
-
' line 3
30
+
' Create an array with some json data
31
+
A << {name: "Ben", age: 20}
32
+
A << {name: "Alice", age: 22}
35
33
36
-
' Save the string. This will create the file myfile.txt in
34
+
' Save the array. This will create the file myfile.txt in
0 commit comments