%*:format% Special

The %*:format% command is used by the Edit Report Templates dialog in the File Line Mask.

This command is mostly used to find and extract text from files in the FAR file list.
We typically use it to scrap together fragments of information from text reports and XML files.

Command Description
%*:line:n% Line: Set the line pointer for the current file. First line is n=1.
eg. %*:line:1%  -- Move pointer to first line of current file.
Line pointer can not be set < 1. Line pointer is initialized to 1 as each file is read.
%*:line+:n% Line+: Add n to the line pointer of the current file.
eg. %*:line+:1%  -- Increment line pointer by one.
%*:line-:n% Line-: Subtract n from the line pointer of the current file.
eg. %*:line-:3%  -- Decrement 3 from the current line pointer. Line pointer wont set < 1.
%*:StrF:ssss% Str Find: Starting from the current line (see line pointer commands above), search for string ssss. If found set the current line pointer to the match line. Search is not case sensitive. No text is returned by this command. The line pointer is moved to the match line.
%*:StrF:ssss:n:c% Str Find: Same as previous command. Also returns text from the current line starting at character position n (1 based) and length c. Search is not case sensitive.
eg. %*:StrF:hello:12:20% --- searches from current line onwards. Looks for line containing text "Hello". Once found returns up to 20 char string starting at char 12 (first char = 1). The result is trimmed of leading and trailing spaces.
If the field width c is omitted or c='*' then FAR automatically finds and returns the next parameter found at or after char position n.
%*:StrA:ssss% Str After: Search for string ssss (starting from current line). If found returns the rest of the line after the match. The result is trimmed of leading and trailing spaces. The line pointer is moved to the match line.
%*:StrA:ssss:n:c% Str After: Same as previous command. You can specify how much of the after string to return. n is the start of the text after the match and c is the width of the text you want. The result is trimmed of leading and trailing spaces. First char after match is n=0.
If the field width c='*' then FAR automatically finds and returns the next parameter found.
eg. %*:StrA:hello:0:999%  -- Gives same result as %*:StrA:hello%
eg. %*:StrA:hello:2:999%  -- Same but skips 2 chars after 'hello' text before grabbing the text.
eg. %*:StrA:hello:2:*%  -- The * will find the next parameter automatically. So a source line "say hello:: Fred B. Smith" with return 'Fred'.
%*:StrC:n:c% Str Copy: Copy substring from the current line. From character position n and length c. The result is trimmed of leading and trailing spaces. First character in line is n=1. If the field width c is omitted or c='*' then FAR automatically grabs the the next parameter found at or after char position n.
eg. %*:StrC:9:*% -- For the line "This is param1 and param2" %*:StrC:9:*% will be replaced by "param1".

 

Example

Because scrapping commands get long, it is best to store the File Line Mask in a separate text file.
For example in the File Line Mask field enter (see Edit Report Templates dialog)...

@file:c:\yourpath\yourfile.txt

This command says, load the Line mask from the specified file ignoring all line-feed characters. Because it ignores line-feeds you can spread your commands out on different lines so they become more readable. FAR sees the file as one long text string minus line-feeds. Use the || chars to force a line break. If you want the line-feeds then use the command @fileCRLF: instead (this replaces line-feeds with the break command || as it reads the file).

Here is an external line mask file we have recently create to create a .CSV file

1

2



3


4



5


6




7

8

9






10
 
%fpath%,

%*:StrA:System #%,
%*:StrA:System Type:1%,
%*:StrA:Created:1:*%,

%*:StrF:Spectrum Test%
%*:StrA:Igram (UDR-2) minimum value =:1:*%,

%*:StrF:Single Beam value at peak =%
%*:StrC:34:*%,
%*:StrC:44:*%,

%*:StrA:Single Beam value at 4000 cm-1 =:1:*%,
%*:StrA:Single Beam value at 6000 cm-1 =:1:*%,

%*:StrA:line value at 4100 cm-1 =:0:*%,
%*:StrA:line value at 2500 cm-1 =:0:*%,
%*:StrA:line value at 1000 cm-1 =:0:*%,
%*:StrA:line value at 500 cm-1 =:0:*%,

..... etc

%*:StrF:Base Movement%

%*:line+:3%%*:StrC:13:*%,
%*:line+:1%%*:StrC:13:*%,
%*:line+:1%%*:StrC:13:*%,
%*:line+:1%%*:StrC:13:*%,
%*:line+:1%%*:StrC:13:*%,
%*:line+:1%%*:StrC:13:*%,

%*:line-:5%%*:StrC:25:*%,
%*:line+:1%%*:StrC:25:*%,
%*:line+:1%%*:StrC:25:*%,
%*:line+:1%%*:StrC:25:*%,
%*:line+:1%%*:StrC:25:*%,
%*:line+:1%%*:StrC:25:*%,
 

We are generating a .CSV (coma delimitated text file) hence the trailing comas on commands producing text output. Commands such as %*:line:1% and %*:StrF:sss% produce no text output. They simply move the current line pointer. So we don't add a coma after these commands.

The output (for a single file in the FAR file list) looks something like this...

D:\TestData\010-0221-0917\Summary.txt,010-0221-0917,Solar,6/24/04,-1.11,9.94,777, .... etc ...
-0.0097,-0.0027,-0.0042,0.0067,0.0011,-0.0008,0.0038,-0.0029,0.0022,0.0044,0.0171,0.0009,

Here is part of the data file D:\TestData\010-0221-0917\Summary.txt.

 SUMMARY for System # 010-0221-0917

System # 010-0221-0917
System Type: Solar
Filename: c:\test.aic
Created: 6/24/04 11:56:56 AM

Spectrum Test PASS

Igram (UDR-2) minimum value = -1.11 volts
Allowed value is between -6.0 and -9.0 volts

Single Beam value at peak =      9.94  at  777 cm-1
Single Beam value at 4000 cm-1 = 6.37 - 64% of peak
Single Beam value at 6000 cm-1 = 0.87 - 09% of peak

...

 Base Movement
 Results 1-6
--------------------------------------------------------------
    1        -0.0097     0.0038
    2        -0.0027     -0.0029
    3        -0.0042     0.0022
    4        0.0067     0.0044
    5        0.0011     0.0171
    6        -0.0008     0.0009
 

 

Example explained

The sections of the Line Mask File (above) are marked 1 to 10.

  1. %fpath% is simply replaced by the current filename (current file being process from the FAR file list).
  2. %*:StrA:System #% searched down the file for the string "System #" and returns the text after that (up until the end of the match line).
    The internal line pointer has now moved down to the line where "System #" was found. All future Str finds etc will now begin at that line.
    To search from the top again you would need to use the %*:line:1% command.
  3. %*:StrF:Spectrum Test% moves the line pointer down to the next line containing text "Spectrum Test".
    %*:StrA:Igram (UDR-2) minimum value =:1:*% then finds text "Igram (UDR-2) minimum value =" and returns the next text parameter found a char after the end of the match.
  4. %*:StrF:Single Beam value at peak =%  moves the line pointer down to the next line containing text "Single Beam value at peak =".
    %*:StrC:34:*%,%*:StrC:44:*%, -- These commands extract parameters at column 34 and 44 of the current line.
  5. ... much the same ...
  6. ... much the same ...
  7. ... etc ...
  8. %*:StrF:Base Movement% - Moves the file pointer down to the next line containing text "Base Movement".
    Below this heading are 2 columns of text on 6 lines. We now want to read each column one at a time.
  9. %*:line+:3% move 3 lines down. This is the top of the 2 data columns.
    %*:StrC:13:*% reads the parameter at column 25.
    %*:line+:1%%*:StrC:25:*% -- repeating these 2 commands reads the rest of the column text.
  10. We want to move to the top of the table again and read the next column.
    %*:line-:5% takes us back 5 lines to row 1 of the table.
    %*:line+:1%%*:StrC:25:*% -- repeating these 2 commands reads all the data in column 25.

Play with it. It's not as hard as it seems.


http://www.HelpwareGroup.com/