SaveArray()

Summary

Saves an array to a file.

Changes

In Version 2017 added saving to a native JSON text file.

Syntax

SaveArray(array my_array, string file_name)

Argument Contents
my_array The array whose contents are saved
file_name The filename, including full or partial path, of the file in which to save the array

Notes

  • The array can contain nested sub-arrays.

  • For more information on full and partial paths, see Identifying Files and Folders.

  • Use WriteArray() to save an array as strings in a text file that can be read by ReadArray().

  • If you save a GISDK option array to a file with extension ".js" or ".json" it will be saved in proper JSON (JavaScript Object Notation) literal object format.

  • The output GISDK array must be a proper options array with string keys.

  • You can also convert between option arrays and JSON text files with ArrayToJson() and JsonToArray().

Error Codes

Error Type Meaning
Error The file cannot be created or overwritten, or the array contains an object that cannot be saved.

See Also

Function Summary
ArrayToJson() Converts an options array to a proper JSON literal object
JsonToArray() Converts a proper JSON literal object to an options array
LoadArray() Loads an array from a file
WriteArray() Writes the elements of an array to a text file