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". |
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 |
The sections of the Line Mask File (above) are marked 1 to 10.
Play with it. It's not as hard as it seems.