export
export
PATH
,
FORMULA
,
SEPARATOR
,
ENCODING

The export statement exports the selected rows in the current database into a text file.

Parameters

This statement has four parameters:

path – is a path to the file to be saved, including the file name (see Files and Folders for more information about file paths).

formula – is the formula that will be used to extract data from the database and build the exported text. If the formula results in empty text ("") for a record then that record will not be exported. The formula usually references fields in the database being scanned. If may also use the seq( function to include the number of each record (within the scan).

To export line items add a Ω (Option-Z) after the line item field names in the formula. Each line item will be output on a separate line. Warning: All the line item fields must have the same number of fields, for example Qty1…Qty6, Price1…Price6, etc. If some line items have more or less fields, the export will not work correctly. Remember, any field name that ends with a number will be treated as a line item, so if your invoice database contains fields named Address1 and Address2 you will not be able to export the line items using this method.

separator – is the separator character that will be inserted in between records in the output text. This parameter is optional, if it is omitted, then no separator will be inserted (you can also include it in the formula itself, though this will result in an extra separator being added at the end of the exported text file).

encoding – name or numeric value of the encoding scheme used to store the text as binary data. Common encodings include:

ASCII (7 bit)
UTF–8 (Unicode)
MacOSRoman (used by OS 9)

The encoding parameter is optional. If it is omitted, `UTF-8` encoding will be used. If the encoding value is preceded by the word lossy (for example `"lossy MacOSRoman"`) then lossy conversion is allowed (see below for more information about lossy conversion).

Note: Spaces and punctuation in this parameter are ignored, and names may be in either upper or loser case. For example `"Mac OS Roman"`, `"MACOSROMAN"` and `"Macos Roman"` will all work for specify Mac OS Roman encoding. You can also specify the encoding numerically, for example 30 for Mac OS Roman. See the texttobinary( function for a full list of encoding names and numeric values.

Description

This statement exports data by scanning the current database and processing each record with a formula (similar to arraybuild, but builds a text file instead of an array). The result of the formula is placed into a text file. By changing the formula you can control what data is exported, and the arrangement of the data in the exported text.

This example exports the contents of a Contact database into a text file containing names and phone numbers.

    export "~/Documents/Phone Book.txt",Last+", "+First+" - "+Phone,lf()

Here is a more complete example that prompts the user for a location to save the text file, then exports mailing list data.

    local fileChoice
    savedialog fileChoice,".txt"
    if info("dialogtrigger") contains "cancel" rtn endif
    export fileChoice,First+" "+Last+", "+Address+", "+City+", "+State+" "+Zip,lf()

The data is normally exported using UTF–8 encoding, but you can add a fourth parameter to specify alternate encodings. For example, if you wanted to import the data into an older version of Panorama (6.0 or earlier) you should use Mac OS Roman encoding, and you should also use carriage returns as the separator instead of linefeeds. If the current database is named Inventory, this example will export a text file named Inventory_export.txt, which contains a tab separated text export of all of the data in the Inventory database.

    export info("databasename")+"_export.txt",exportline(),cr(),"Mac OS Roman"

Error Messages

Assorted error messages – If the formula supplied by the user contains an error, the operation is aborted and the error is returned.

See Also

- appenddataarrays( -- appends two or more data arrays to each other (see Data Arrays).
- array( -- extracts a single data item from a text array or a data array (see Text Arrays and Data Arrays).
- arrayboth -- creates a new array from two existing arrays. The new array contains only items that are in both of the original arrays.
- arrayboth( -- creates a new array from two arrays. The new array contains only items that are in both of the original arrays.
- arraybuild -- builds an array by scanning a database and creating an array element for every record (including invisible records) in the database (see Text Arrays).
- arraybuild( -- builds an array by scanning a database and creating an array element for every record (including invisible records) in the database (see Text Arrays).
- arraychange( -- changes the value of a single data item in a text array or a data array (see Text Arrays and Data Arrays).
- arraycolumn( -- extracts a column from a two dimensional array.
- arraycontains( -- checks to see if any element of a text array or a data array matches a specified value.
- arraydeduplicate( -- removes duplicate elements from a text array (see Text Arrays).
- arraydelete( -- deletes (removes) one or more elements from a text array or a data array (see Text Arrays and Data Arrays).
- arraydeletevalue( -- deletes any array elements that match the value parameter. This must be an exact match, including upper and lower case. If the value occurs multiple times in the array, every occurence of the value will be removed, with one exception: if the value occurs in two consecutive array elements, only the first occurence will be deleted.
- arraydifference -- creates a new array from two existing arrays. The new array contains only items that are in the first array but *not* in the second array.
- arraydifference( -- creates a new array from two existing arrays. The new array contains only items that are in the first array but *not* in the second array.
- arrayelement( -- converts between character positions and array element numbers in a text array.
- arrayfilter( -- processes each element of a text array or a data array with a formula (see Text Arrays and Data Arrays).
- arrayfirst( -- extracts the first element of a text array.
- arrayhack( -- hacks an array by adding, replacing or removing array elements
- arrayinsert( -- inserts one or more empty elements into the middle of a text array (see [Text Arrays]).
- arrayitemsandwich( -- adds a prefix and/or suffix to each non-blank item in a text array.
- arrayitemtrim( -- removes characters from the beginning and/or end of each item in an array.
- arraylast( -- extracts the last element of an array.
- arraylefttrim( -- removes one or more elements from the beginning of an array.
- arraylookup( -- uses a key to look up a value in a two dimensional text array containing key/value pairs (see Text Arrays).
- arraymerge( -- merges two text arrays together (see [Text Arrays]).
- arraymultisort -- sorts a two-dimensional array on the key of one or more of its columns.
- arraymultisort( -- sorts a two-dimensional array on the key of one or more of its columns.
- arraynotcontains( -- is the reverse of arraycontains(. it returns *false* if the value is in the array, *true* if it is not in the array.
- arraynumericsort( -- sorts a text array in numeric order (see Text Arrays).
- arraynumerictotal -- totals all the numeric elements of a text array.
- arraynumerictotal( -- totals all the numeric elements of a text array.
- arrayrandomize -- reorders an array in random order.
- arrayrandomize( -- reorders an array in random order.
- arrayrange( -- extracts a series of data items from a text array or a data array (see Text Arrays and Data Arrays).
- arrayrelocate -- moves one or more items in a text array to a new position.
- arrayrelocate( -- moves one or more items to a new position in a text array or a data array (see Text Arrays and Data Arrays).
- arrayreplacevalue( -- changes array elements that match a specified value.
- arrayreverse( -- reverses the order of the elements in a text array or a data array (see Text Arrays and Data Arrays).
- arrayreverselookup( -- uses a value to look up a key in a two dimensional text array containing key/value pairs (see Text Arrays).
- arraysearch( -- searches a text array or a data array (see Text Arrays and Data Arrays) to see if it contains a specific value.
- arrayselectedbuild -- builds an array by scanning a database and creating an array element for every visible (selected) record in the database (see Text Arrays).
- arrayselectedbuild( -- builds an array by scanning a database and creating an array element for every visible (selected) record in the database (see Text Arrays).
- arraysize( -- returns the number of elements in a text array or a data array (see Text Arrays and Data Arrays).
- arraysort -- sorts the elements in an array (see Text Arrays).
- arraysort( -- alphabetizes (A-Z) the elements in a text array (see [Text Arrays]).
- arraystrip -- strips blank elements from an array.
- arraystrip( -- removes any blank elements from a text array or a data array (see Text Arrays and Data Arrays).
- arraytableceiling( -- looks up a value in a double column table, similar to the table( function but from an array instead of a database.
- arraytablefloor( -- looks up a value in a double column table, similar to the table( function but from an array instead of a database.
- arraytoggle -- "toggles" a value within an array.
- arraytopythonlist( -- converts a Panorama array into a Python list.
- arraytrim( -- removes one or more elements from the end of an array.
- arrayunpropagate -- scans an array from top to bottom, removing duplicate values in a row.
- arrayunpropagate( -- scans an array from top to bottom, removing duplicate values in a row.
- chararray( -- extracts a single character from text.
- commalist( -- converts a text array (see Text Arrays) into an English list, with items separated by a comma and a space, except for the last two items which are separated by the word *and* and spaces.
- commatocr( -- converts a comma delimited array into a carriage return delimited array.
- csvtotsv( -- converts comma separated text into tab separated text.
- Data Arrays -- A numbered collection of data values.
- dataarray( -- creates a data array from one or more separate values (see Data Arrays).
- dataarrayappend( -- appends one or more values to the end of an existing array.
- dataarraybuild( -- builds a data array by scanning a database and creating an array element for every record (including invisible records) in the database (see Data Arrays).
- dataarrayinsert( -- inserts one or more values into the middle of an existing array.
- dataarrayselectedbuild( -- builds a data array by scanning a database and creating an array element for every visible record in the database (see Data Arrays).
- exportdataarray( -- converts a data array into a text array (see Data Arrays and Text Arrays).
- extract( -- extracts a single data item from a text array, and can also be used to count the number of items in the array.
- generatedataarray( -- generates a new data array based on a formula (see Data Arrays and Text Arrays).
- htmlarraytable -- generates an HTML table from an arrray.
- htmldatamerge -- uses a template to generate HTML you want from a database.
- htmldatatable -- generates an HTML table from selected data in the current database.
- htmltabletoarray -- converts an HTML table into a text array.
- importdataarray( -- converts a text array into a data array (see Data Arrays and Text Arrays).
- lineitemarray( -- converts the data in a set of line item fields into a text array (see Text Arrays).
- linescontain( -- checks to see if any line in a carriage return separated array matches the specified value.
- linesnotcontain( -- is the reverse of the linescontain( function.
- linesort( -- sorts lines of text in ascending order.
- linestrip( -- removes any blank lines from the text.
- makenumberedarray -- generates a numeric sequenced text array.
- makenumberedarray( -- generates a numeric sequenced text array.
- randomarrayelement( -- returns a random element from an array.
- randomline( -- returns a random line from multiple lines of text.
- randomword( -- returns a random word from a list of words.
- setfieldproperties -- modifies one or more properties (name, data type, formula, etc.) of the current field.
- superarraybuild -- scans a database to create a text array. This statement is is similar to arraybuild, but with a number of additional options (see Text Arrays).
- tabarray( -- extracts the nth element from a tab delimited array.
- tagarray( -- builds an array (see Text Arrays) containing the body of all the specified tags (usually HTML tags) in the text.
- Text Arrays -- A numbered collection of text values.
- tsvtocsv( -- converts tab separated text into comma separated text.
- tsvtojson( -- converts tab separated text into JSON formatted text.

History

Version | Status | Notes
10.0 | Updated | Carried over from Panorama 6.0, but now includes an optional separator character and encoding type.