Odb
 
Format #1 Odb v1 [v2 v3 v4...]  
Purpose Same as OutEnd,but separates the fields with vertical bars
Parameters Same as OutEnd
Similar Cmds OutRuler

You can use the Odb (“Output Debug ”)command while developing or fixing a script.The vertical bars let
you see if the variables have spaces on either side.Once your script is working properly,you can do a quick
search for “Odb ” to see if you left behind any debug lines.
 
OutCSV
 
Format OutCSV v1 [v2 [v3 v4 v5...]]
Examples OutCSV '''Init'
OutCSV CustName
OutCSV ItemPrice 'Unquoted'
OutCSV '''Done'
Purpose Generates CSV (Comma Separated Value)output;can also be used
to generate columnar reports with columns that can be turned
on and off
Parameters v1 -Value to send to output (or control information)
v2 -Control setting
v3 -If present,v3 and subsequent values are concatenated to v1
Controls The format of v2 is:
[+/-][Init/Done/Stop/Quoted [...]/Unquoted [...]/Control ]
'Init'starts the accumulation of a new line of CSV output.
'Done'sends the accumulated output to the output file.
'Stop'terminates accumulation without sending output.
'Quoted'puts quotes around the field.
'Unquoted'adds the field without quotes.
'+'and '-'turn fields on and off.
'...'changes the default quoting state
'Control'adjusts OutCSV settings.
Defaults v2 ='Quoted'(unless default quoting state has been changed)
Similar Cmds OutEnd,Odb
Notes Nothing is actually sent to the output file until the 'Done'
step (i.e.v2 ='Done').
 
The various controls are explained in more detail below.
 
OutCSV Init
 
When v2 is 'Init',v1 can be used to specify an alternative separator (other than the usual comma).Typical alternatives include the semicolon (;)and the Tab (ASCII decimal 9).To save you having to look up ASCII values,OutCSV recognizes certain codes for the separator.Here is an overview of the v1 settings...
 
—————— ————————————————————————————————————————————————————————————
v1 Explanation
—————— ————————————————————————————————————————————————————————————
'' Use default field separator — this is usually a comma
',' You can also specify a comma explicitly
'TAB' The tab character
'CR' The carriage-return character
'CRLF' The carriage-return and linefeed characters
'LFCR' Linefeed then carriage-return (non-standard —rarely used)
'NONE' No separator (remember:if you use ''it means “default ”)
—————— ————————————————————————————————————————————————————————————

You can,in fact,set the separator to any string.Used with padded text (or OutCSV's Control setting with the MaxWidth and MinWidth options),you can use OutCSV to generate columnar reports.Your script can then turn entire columns on and off using the '+'and '-'feature.
 
Outputting a Field
 
When v2 is 'Quoted'or 'Unquoted'or null,OutCSV accumulates the field for the current output line.The
line is not actually sent to output until the 'Done'step is reached.Here is a brief example:

OutCSV '''Init'
OutCSV 'Fred Jones'
OutCSV 1234.56 'Unquoted'
OutCSV '''Done'
 
This will output a two-field CSV line,with quotes around the first field but not the second one.If the field is
quoted,any occurrence of the quote character (")is replaced by double-quotes,as per standard CSV
conventions.
 
OutCSV Nulls
 
If you have several null fields to insert,you can use the Nulls option:
OutCSV 5 'Nulls'
This would accumulate 5 null fields for the current output line.
Nothing is done if the parameter is 0 (zero)or a null ('').If the value is more than 1000,OutCSV stops with
an error message.
 
OutCSV Done and Stop
 
When v2 is 'Done',OutCSV sends the accumulated line to the output file.The v1 value is not used.

An infrequently used alternative to 'Done'is 'Stop'.In this case,the output is not sent to the output file but is saved in the special variable $OutCSVRec.You can use this method if you do not wish to send the output
immediately.In such case,you should copy the result from $OutCSVRec to another variable before doing
another set of OutCSV commands.
 
OutCSV Control
 
When v2 is 'Control',OutCSV consults v1 for a command that configures how it will operate.Control
settings remain in effect within the script until changed.

The following options are available:
 
————————— ————————————————————— ————————————————————————————————————————————
Command Example Explanation
————————— ————————————————————— ————————————————————————————————————————————
MinWidth 'OutCSV 'MinWidth 25' Pad fields (with spaces)to specified width
MaxWidth OutCSV 'MaxWidth 25' Truncate fields that exceed specified width
SetWidth OutCSV 'SetWidth 15' Set MinWidth and MaxWidth to the same value
QuoteChar OutCSV 'QuoteChar @' Specify new character for quoting fields
Separator OutCSV 'Separator ;' Change default separator (originally comma)
————————— ————————————————————— ————————————————————————————————————————————
To set the quoting character to a space,use 'QuoteChar Space'.When the QuoteChar is a space,it is not doubled-up when it is found in a field,since the only reason one would set the QuoteChar to a space is to create columnar reports.

You can also use 'QuoteChar None'to mean “don't put any quoting characters around purportedly quoted
fields ”.This feature is useful if you are using OutCSV to produce columnar reports.

The MaxWidth and MinWidth settings take into account the presence or absence of quotes when calculating width.Also,unquoted fields are assumed to be numeric and (if necessary)are padded on the left,while quoted fields are padded on the right.
 
Turning Fields On and Off
 
Whenever the first character of v2 is '-'(the minus character),all subsequent fields are “turned off ”.To turn them back on,set the first character of v2 to '+'(the plus character).Here is an example:
 
OutCSV '''Init'  
OutCSV 'Fred Jones' ;Customer name field
OutCSV 1234.56 '-Unquoted' ;Current balance
OutCSV '416-555-1212''+' ;Customer phone number
OutCSV '''Done'  
In this example,the “Current balance ” field will not appear in the output.

The ability to turn fields on and off can greatly simplify the testing of scripts that generate CSV output.You
can also use this feature to create reports with columns that can be turned on and off.
 
Changing the Default Quoting State
 
The default state for OutCSV field accumulation is 'Quoted'.However,sometimes you have a lot of 'Unquoted'fields in a row and it is a chore to have to type 'Unquoted'repeatedly.You can redefine the default state by putting an ellipsis (three periods)after 'Quoted'or 'Unquoted'.Here is an example:
 
OutCSV '''Init'
OutCSV 1
OutCSV 2 'Unquoted...'
OutCSV 3
OutCSV 'A''Quoted...'
OutCSV 'B'
OutCSV '''Done'
 
This would output the following line:
"1",2,3,"A","B"
This alteration to the default only lasts until the 'Done'step;OutCSV always starts with the default state of 'Quoted'.
 
Switchable CSV/Columnar Reports
 
Here is an example of some code that can be easily switched between CSV output and columnar output,
simply by changing one variable (called MyVar here):
 
CSVDelim ='' ;Normal setting (i.e.“use a comma")
Begin MyVar ='Y' ;Did we turn on columnar mode?
CSVDelim ='' ;Separate fields with space,not comma
OutCSV 'MinWidth 15''Control' ;Pad fields out to 15 characters
OutCSV 'MaxWidth 15''Control' ;Truncate any fields wider than 15
OutCSV 'QuoteChar None''Control' ;Ignore the quotes around quoted fields
End  
OutCSV CSVDelim 'Init' ;Start of OutCSV accumulation
OutCSV FirstName ;A quoted field
OutCSV LastName ;A quoted field
OutCSV Balance 'Unquoted' ;Unquoted field (typical for numbers)
OutCSV '''Done' ;Send fields to output file
 
Simply by setting the variable MyVar to 'Y',a CSV (Comma Separated Value)file becomes a columnar report.The result may not be elegant,but if you are looking for fast results without having to load the output into a spreadsheet,this can be a real time-saver.
 
OutCSV Examples
 
Some script-enabled Parse-O-Matic applications include a sample script named ScrPSTOutCSV.txt .It provides examples of the techniques described above.If you do not have this script but would like a copy, please write to us.You can also find CSV-oriented sample scripts in the Pyroto,Inc.Knowledge Base, available at www.Parse-O-Matic.com.
 
OutEnd
 
Format OutEnd v1 [v2 v3 v4...]  
Examples OutEnd 'Customer List'
OutEnd 'Customer Name:'CustName
;One value to output
;Two values to output
Purpose Sends data to the output file,followed by a Carriage-Return and
a Linefeed (the standard end-of-line characters for text files)
Parameters v1 -Value to send to output file
v2 -Value (any number of values can be appended)
Similar Cmds OutNull,Output,OutRuler
 
OutFile
 
Format OutFile v1 [v2 ]  
Examples OutFile 'C:\MyFiles \Output.txt''Append'
 
Purpose Changes the current output file
Parameters v1 -Name of the output file
v2 -Control setting
Controls 'New'=Start with an empty file
'Append'=Add to the end of the file (if it exists)
Defaults v2 ='New'
 
If the file name is not fully qualified (i.e.does not contain a path)the file will be placed in the default output folder,as set by the Path button.

If a file is opened as New and a file already exists with that name,the old file is renamed with a .bak extension.For this reason,you should not use OutFile to switch to a file with a .bak extension.

The fully-qualified name of the current output file is found in the $ActualOFN variable.If you copy this value into a variable,you can return to the original output file later on by using OutFile with 'Append'.
 
OutNull
 
Format OutNull  
Purpose Sends a blank line to the output file (i.e.just a Carriage-
Return and a Linefeed).
Similar Cmds OutEnd,Output,OutRuler
 
Output
 
Format Output v1 [v2 v3 v4...]  
Purpose Same as OutEnd,but does not send “end-of-line ” characters
Parameters Same as OutEnd
Similar Cmds OutEnd,OutNull,OutRuler
 
OutRuler
 
Format OutRuler v1 [v2 v3 v4...]
Purpose Same as OutEnd,but includes a measuring scale
Parameters Same as OutEnd
Similar Cmds Odb
 
You can use OutRuler while developing a script to help you measure where columns start and end.It outputs the line as OutEnd does,but includes a measuring scale above it.

(This page is part of the online user manual for Parse-O-Matic.  Parse-O-Matic is a programmable parsing tool that can extract, manipulate, convert or mine existing data sources and turn them into importable data.  For more information on Parse-O-Matic products and conversion services, please visit www.ParseOMatic.com)