nw:save-to-string
nw:save-to-string format
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, and is useful in NetLogo Web and other contexts where the result needs to go somewhere other than the file system.
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:
dlgdfgexfgmlgraphmlmatrixvna
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.
For example, to save a network and hand it off to a browser download in NetLogo Web:
let gml nw:save-to-string "gml"
send-to:file "my-network.gml" gml