 |
| |
| Overview |
| |
| This section documents the specific decapsulator commands.For a broader overview of decapsulators, please see the Decapsulators section of this user manual. |
| |
| Insert |
| |
| Parse-O-Matic Scripting supports several types of comparators: |
| |
| Format |
Insert v1 d2 v3 [v4 ] |
|
| Examples |
Insert Var '10''Cat'
Insert Var '-1''X'
Insert Var '>*A''Y'
Insert Var 'B''Z''Exclude' |
;Insert 'Cat'at column 10
;Insert 'X'before last char
;Insert 'Y'before last 'A'
;Insert 'Z'after first 'B' |
| Purpose |
.Inserts v3 into v1 at the position determined by d2 |
| Parameters |
v1 -Variable being modified
d2 -Decapsulator
v3 -Value to insert at the position found by v2
v4 -Decapsulator control settings |
| Controls |
Exclude/Include;IgnoreCase/MatchCase |
| Defaults |
v4 ='Include MatchCase'("Include ” means “insert before ”) |
| Similar Cmds |
Change,Overlay |
| Notes |
If decapsulator d2 is not found,nothing is done.
Sets $Success ('Y'=decapsulator value was found). |
|
| |
| Overlay |
| |
| Here is a list of the literal comparators: |
| |
| Format |
Overlay v1 d2 v3 [v4 ] |
|
| Examples |
Overlay MyVar '10''Cat'
Overlay MyVar '<*A''X'
Overlay MyVar '3*B''Y'
Overlay MyVar '>*C''Z' |
;Overlay 'Cat'at column 10
;Overlay first 'A'with 'X'
;Overlay third 'B'with 'Y'
;Overlay last 'C'with 'Z' |
| Purpose |
Overwrites v1 with v3 at the position determined by d2 |
| Parameters |
v1 -Variable being modified
d2 -Decapsulator
v3 -Value to overwrite at the position found by v2
v4 -Decapsulator control settings |
| Controls |
Exclude/Include;IgnoreCase/MatchCase |
| Defaults |
v4 ='Include MatchCase' |
| Similar Cmds |
Change,Insert |
| Notes |
If decapsulator d2 is not found,nothing is done.
If necessary,v1 will be lengthened to make room for v3.
Sets $Success ('Y'=decapsulator was found). |
|
| |
| Parse |
| |
| With some restrictions (discussed later),literal comparators work on both numeric and alphabetic data.Here are some examples of literal comparisons that are true: |
| Format |
v1 =Parse v2 d3 [d4 [v5 ]] |
| Examples |
See below |
| Purpose |
Parses free-form data |
| Parameters |
v1 -Variable being set
v2 -Value being searched
d3 -“From ” decapsulator
d4 -“To ” decapsulator
v5 -Decapsulator control settings |
| Controls |
Exclude/Include;IgnoreCase/MatchCase;Cut;Relaxed |
| Defaults |
d4 =''(Null decapsulator,meaning “to the end of the line")
v5 ='Exclude MatchCase' |
| Similar Cmds |
FindPosn,ScanPosn |
|
| |
| Parse is one of the most powerful commands in the Parse-O-Matic Scripting repertoire.For an introduction to working with decapsulators (along with many examples of the Parse command),please see the Decapsulators section of this user manual. |
| |
| The “Cut ”Control Setting |
| |
| The Cut control setting removes the text that is found in the variable being examined,along with the encapsulating text. This technique is particularly useful when using a technique called “Left-Peeling ”. Consider the following script: |
MyVar = 'John,Aloysius,Smith'
FirstName = Parse MyVar ''',''Cut' ;Cut out first name
MidName = Parse MyVar ''',''Cut' ;Cut out middle name
LastName = MyVar ;Save what's left |
This “peels ” off fields from the left side of the variable MyVar..It will set the variable FirstName to 'John',
the MidName variable to 'Aloysius',and LastName to 'Smith'. |
| |
| The “Relaxed ”Control Setting |
| |
The “Relaxed ” control setting lets the “To ” decapsulator look for text that may not be there..If it is not there, the “To ” decapsulator is treated like a null (('')decapsulator.
Let us say you are extracting information from the $OutData special variable and some of the lines you have to parse look like this: |
Bob
Fred Smith
Mary Anastasia Jones
John Quincy Publique Sr. |
This data is inconsistent,so you cannot predict how many parsing cuts to make.With the “Relaxed ” control
setting,this is not a problem.
Consider the following example. |
Name1 = Parse $OutData '''''Cut Relaxed'
Name2 = Parse $OutData '''''Cut Relaxed'
Name = Parse $OutData '''''Cut Relaxed'
Name4 = Parse $OutData '''''Cut Relaxed'
Name = Name1 '/'Name2 '/'Name '/'Name4 '/' |
| This would set the Name variable to the following values: |
Bob
Fred/Smith
Mary/Anastasia/Jones
John/Quincy/Publique/Sr. |
| The preceding example could,of course,have been accomplished more easily with the Change command, but it is included here as a demonstration,not a real-world application. (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) |
| |