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: README.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,6 +208,7 @@ There may be rare occasions in which you don't want the NW extension to remember
208
208
[`nw:load`](#nwload)
209
209
[`nw:load-from-string`](#nwload-from-string)
210
210
[`nw:save`](#nwsave)
211
+
[`nw:save-to-string`](#nwsave-to-string)
211
212
212
213
### Centrality Measures
213
214
@@ -1398,6 +1399,35 @@ Limitations:
1398
1399
1399
1400
1400
1401
1402
+
### `nw:save-to-string`
1403
+
1404
+
```NetLogo
1405
+
nw:save-to-string format
1406
+
```
1407
+
1408
+
1409
+
Serialize the current network context to a string in the given format and report it, rather than writing to a file. This is the counterpart to [`nw:load-from-string`](#nwload-from-string), and is useful in NetLogo Web and other contexts where the result needs to go somewhere other than the file system.
1410
+
1411
+
The `format` argument names the format explicitly and takes the same values as `nw:load-from-string`. It is case-insensitive and an optional leading dot is ignored, so `"gml"`, `"GML"`, and `".gml"` are all equivalent. The supported formats are:
1412
+
1413
+
-`dl`
1414
+
-`gdf`
1415
+
-`gexf`
1416
+
-`gml`
1417
+
-`graphml`
1418
+
-`matrix`
1419
+
-`vna`
1420
+
1421
+
Aside from reporting a string instead of writing to a file, `nw:save-to-string` behaves exactly like the corresponding `nw:save-*` primitive, with the same limitations regarding attributes and multigraphs.
1422
+
1423
+
For example, to save a network and hand it off to a browser download in NetLogo Web:
1424
+
1425
+
```
1426
+
let gml nw:save-to-string "gml"
1427
+
```
1428
+
1429
+
1430
+
1401
1431
## Building
1402
1432
1403
1433
The extension is written in Scala (version 2.9.2).
Copy file name to clipboardExpand all lines: documentation.conf
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1202,6 +1202,35 @@ Limitations:
1202
1202
- Multigraphs are not supported. Thus, two turtles can share at most one link. `nw:save-graphml` does support multigraphs, so use that if turtles can have more than one type of link connecting them.
1203
1203
1204
1204
`nw:save` determines the file-type of the given file based on the extension and calls the corresponding `save-*` primitive on it. Note that GraphML must be exported with `nw:save-graphml`.
1205
+
"""
1206
+
},
1207
+
1208
+
{
1209
+
name: save-to-string,
1210
+
type: reporter,
1211
+
returns: string,
1212
+
tags: [ io ],
1213
+
arguments: [ {name: format, type: string} ],
1214
+
description: """
1215
+
Serialize the current network context to a string in the given format and report it, rather than writing to a file. This is the counterpart to [`nw:load-from-string`](#nwload-from-string), and is useful in NetLogo Web and other contexts where the result needs to go somewhere other than the file system.
1216
+
1217
+
The `format` argument names the format explicitly and takes the same values as `nw:load-from-string`. It is case-insensitive and an optional leading dot is ignored, so `"gml"`, `"GML"`, and `".gml"` are all equivalent. The supported formats are:
1218
+
1219
+
- `dl`
1220
+
- `gdf`
1221
+
- `gexf`
1222
+
- `gml`
1223
+
- `graphml`
1224
+
- `matrix`
1225
+
- `vna`
1226
+
1227
+
Aside from reporting a string instead of writing to a file, `nw:save-to-string` behaves exactly like the corresponding `nw:save-*` primitive, with the same limitations regarding attributes and multigraphs.
1228
+
1229
+
For example, to save a network and hand it off to a browser download in NetLogo Web:
Copy file name to clipboardExpand all lines: documentation.yaml
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1287,6 +1287,35 @@ primitives:
1287
1287
tags:
1288
1288
- io
1289
1289
type: command
1290
+
- arguments:
1291
+
- name: format
1292
+
type: string
1293
+
description: |2
1294
+
1295
+
Serialize the current network context to a string in the given format and report it, rather than writing to a file. This is the counterpart to [`nw:load-from-string`](#nwload-from-string), and is useful in NetLogo Web and other contexts where the result needs to go somewhere other than the file system.
1296
+
1297
+
The `format` argument names the format explicitly and takes the same values as `nw:load-from-string`. It is case-insensitive and an optional leading dot is ignored, so `"gml"`, `"GML"`, and `".gml"` are all equivalent. The supported formats are:
1298
+
1299
+
- `dl`
1300
+
- `gdf`
1301
+
- `gexf`
1302
+
- `gml`
1303
+
- `graphml`
1304
+
- `matrix`
1305
+
- `vna`
1306
+
1307
+
Aside from reporting a string instead of writing to a file, `nw:save-to-string` behaves exactly like the corresponding `nw:save-*` primitive, with the same limitations regarding attributes and multigraphs.
1308
+
1309
+
For example, to save a network and hand it off to a browser download in NetLogo Web:
0 commit comments