home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-02-18 | 80.0 KB | 1,985 lines |
- __
- / ////
- __ ///
- \ \ /// < < <<< PARex v3.10 >>> > >
- \ \///
- \__//// USER MANUAL - Release : 16-Jan-94
-
- Copyright ©1991-1994 Chris P. Vandierendonck, [AmiSYS].
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- Copyright Notice
- ~~~~~~~~~~~~~~~~
- PARex is released as SHAREWARE, not excluding the copyright and
- all other rights, which remain with the author Chris P.
- Vandierendonck. If you use PARex then you must pay the shareware
- fee and register.
-
- Prior written permission from the author is required to
- distribute PARex and to use PARex in commercial releases, on
- shareware disks, coverdisks or diskmagazines. When distributed,
- all files must be kept together, in their original unmodified
- form.
-
- (AmigaDOS and Workbench are trademarks of Commodore Amiga Inc.)
-
- Disclaimer
- ~~~~~~~~~~
- PARex is provided "AS IS", WITHOUT ANY WARRANTY to its quality,
- performance or fitness for a particular purpose. In no event
- shall the author be liable or responsible to the user or any
- other person, for any kind of damage caused by the use of this
- software.
-
- Shareware registration, suggestions, remarks and bug reports
- about this program can be send to the following address :
-
- Chris Vandierendonck
- Koning Albertstraat 188
- B-8210 VELDEGEM
- BELGIUM
-
- SHAREWARE information
- ~~~~~~~~~~~~~~~~~~~~~
- The DEMO version of PARex only processes the first 12500 bytes
- of the source file!! To receive the unlimited version you must
- pay the shareware fee of 15 US dollars (DEM 20 or GBP 10). The
- ModulaII source code is also available, see the "RegForm" for
- more info.
-
- If possible, use a printout of the 'RegForm' file to register.
- Send this form along with the shareware fee to the above
- address. You can send the money in cash (fastest and cheapest
- way), or by (international) money order payable to Chris
- Vandierendonck. (DO NOT send bankcheques, since they are too
- expensive to clear!)
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 1
-
- Preface
- ~~~~~~~
- PARex is a program to replace certain strings in a file. The
- result can be saved to any file, or back to the source file.
- PARex takes its replace data from the command line or from a
- script file (here an unlimited number of replace strings can be
- defined). Generally PARex will be used on text files, but binary
- files can also be processed.
-
- The power of PARex is found in its data script. Here you can
- define as many replace strings as you want. By which strings
- they should be replaced, can depend on commands used on the
- command line. You can divide the script into several parts,
- which can then be selected at startup.
-
- PARex can be used to replace strings in (text)files, strip
- comments from source code, convert files between different
- computer systems, discard all print control sequences from a
- text file, convert an AmigaGuide file to a normal textfile,
- etc...
-
- PARex is reentrant, so it can be made resident. During execution
- you can terminate PARex by pressing 'CTRL-C'.
-
- System Requirements
- ~~~~~~~~~~~~~~~~~~~
- PARex requires AmigaDOS v1.2 or higher to "perform".
-
- Program Usage (Shell/CLI only)
- ~~~~~~~~~~~~~
- ("?" gets the program format, and "©" the program's copyright and
- version.)
-
- [[FROM] <file|dir|pat>] [[TO] <file|dir>] [CONVERT] [PRT|PAR|SER]
- [NOSCRIPT] [SCRIPT <file[.pxs]>] [GLOBAL] [MODE <name|pat]>] [ALL]
- [READ <#bytes>] [TOUCH <#bytes>] [BUFFER <#bytes>] [LOAD] [STAT]
- [HEXDUMP [<fmtstr>]] [CASECHECK] [UCASE] [LCASE] [TRACE] [SILENT]
- [NOVERSION]
-
- [WHEN <name|pat>] [CAP|DECAP] [WILD] [CONTEXT] [NEST] [FIT] [ZERO]
- [MINSIZE <#bytes>] [MAXSIZE <#bytes>] [LEFTFILL|RIGHTFILL <0.255>]
- [TIMES <#>] [EVERY <#>] [AFTER <#>] [WORD] [TAB <#>]
-
- [[{] INIT <str> [<cmds> }]] [[{] CLOSE <str> [<cmds> }]]
- [[{] REPL <str> BY <str> [<cmds> }]] [[{] CAP <str> [<cmds> }]]
- [[{] STRIP <str> TO <str> [<cmds> }]] [[{] DECAP <str> [<cmds> }]]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 2
-
- TABLE OF CONTENTS
- ~~~~~~~~~~~~~~~~~
- 1. Source and destination file ................................ 3
- 1.1. Source file/directory ................................. 3
- 1.2. Destination file/directory ............................ 3
- 1.3. Advanced options ...................................... 5
- 1.3.1. Reading part of the source file ................ 5
- 1.3.2. Writing directly into the source file .......... 5
- 1.3.3. Buffer sizing .................................. 6
-
- 2. Global converting options .................................. 7
- 2.1. Hexadecimal output .................................... 7
- 2.2. Case conversion ....................................... 8
- 2.3. Dynamic TAB to space replacing ........................ 8
-
- 3. Program information ........................................ 9
- 3.1. Before processing ..................................... 9
- 3.2. During processing ..................................... 9
- 3.3. After processing ...................................... 9
- 3.4. Suppressing information ............................... 10
-
- 4. Main replace commands ...................................... 11
- 4.1. INIT : inserting a string at the beginning of a file . 11
- 4.2. CLOSE : adding a string to the end of a file .......... 12
- 4.3. REPL : replacing one string by another ............... 12
- 4.4. STRIP : removing characters between two strings ....... 13
- 4.5. CAP : putting found string in upper case ............ 14
- 4.6. DECAP : putting found string in lower case ............ 14
- 4.7. Formatting of the searchStr and replStr ............... 14
-
- 5. Search control ............................................. 17
- 5.1. Case-sensitive searching .............................. 17
- 5.2. Wildcard searching .................................... 17
- 5.3. Context remembering ................................... 18
- 5.4. Word-only searching ................................... 19
-
- 6. Program variables .......................................... 20
- 6.1. PARex information ..................................... 20
- 6.2. Inserting files ....................................... 20
- 6.3. Inserting date and time ............................... 21
- 6.4. Inserting path and name of source & destination file .. 22
-
- 7. Using PARex data scripts ................................... 23
- 7.1. Setting up scripts .................................... 23
- 7.2. Script commands ....................................... 23
- 7.3. Script options ........................................ 24
-
- 8. Additional sub-commands .................................... 26
- 8.1. Limit replacing ....................................... 26
- 8.2. Defining the size of the replace string ............... 26
- 8.3. Case conversion ....................................... 28
- 8.4. Making sub-commands to work on all main-commands ...... 28
-
- A. Option reference ........................................... 29
- B. Command reference .......................................... 30
- B.1. Main commands ........................................ 30
- B.2. Sub-Commands ......................................... 30
- B.3. Script Commands ...................................... 30
- C. Variables .................................................. 31
-
-
-
- PARex v3.1x User Manual - Page 3
-
- 1. Source and destination file.
-
- 1.1. Source file/directory.
-
- Option: [FROM] <file|dir|pattern>
-
- » This is the file to be converted. You can also specify a
- directory, which implicates that all files of that directory
- will be processed. If you don't give a source
- file/directory, then PARex will process all files in the
- current directory!
-
- » A pattern can be given in order to only process certain file
- of a given directory or of the current directory. The
- following wildcards are supported : "#", "?", "*" (same as
- "#?"), "'" and "|" (refer to your Amiga systemsoftware
- manual for more information on these wildcards).
-
- | 'PARex RAM:T/*.doc|*.txt' -> only process files in the
- | "RAM:T" directory with the ".doc" or ".txt" suffix.
-
- » The FROM keyword is optional.
-
- !! » If no source file is given, then PARex will process all
- files of the current directory!
-
- NOTE: the source files can be plain text files, as well as
- binary files, such as programs.
-
-
- 1.2. Destination file/directory.
-
- WARNING: only one of the following destination options can be
- used.
-
- Option: [TO] <file|dir>
-
- » This is the destination (target) file. It's the result of
- the converting process. As with the source file, you
- can also specify a directory in which to save the converted
- files.
-
- » If no target file/directory is given (and [CONVERT] or
- [TOUCH] isn't used), then the target file(s) will have the
- same name as the source file(s) except for the ".prx"
- suffix.
-
- !! » The TO keyword is optional, provided a source name has been
- given before this option.
-
- NOTE: the file attributes (protection flags) of the
- sourcefile(s) are preserved. In other words the
- destination file(s) have the same file attributes as
- their source file.
-
- TIP: use "*" to output processed file to the Shell window.
-
- | ' PARex RAM:source * '
- | Will dump the RAM:source file to the Shell window.
-
-
-
- PARex v3.1x User Manual - Page 4
-
- Option: CONVERT
-
- » With this option the source itself will be converted. To do
- this PARex works as follows, first the results are saved to
- a new file. When the processing is finished, the source file
- is deleted and the newly created file is renamed as the old
- source file.
-
- » Since PARex works in this way, you can safely terminate the
- converting process with CTRL-C. Your original source file
- will still be intact!
-
- Option: PRT|PAR|SER
-
- » One of these option keywords sends the output to the
- printer: - PRT uses "PRT:" to output;
- - PAR uses "PAR:" to output;
- - SER uses "SER:" to output.
-
- » You must use one of the last two if your text contains raw
- printer commands, which only your printer understands.
-
- 1.3. Advanced options.
-
- The options discussed in the following points, are intended for
- more advanced users, who know what they're doing.
-
- 1.3.1. Reading part of the source file.
-
- Option: READ <# bytes>
-
- » The READ option forces PARex to only process the given
- number of bytes of the source file.
-
- | ' PARex RAM:source READ 500 REPL a BY b '
- | In this case PARex will only read 500 bytes of the
- | source file 'RAM:source', convert all a's to b's, and
- | write the result to 'RAM:source.prx'.
-
- WARNING: don't ever use an option which writes back to the
- source file, unless you know what you're doing. The
- rest of your source file will definitely be lost!
-
- 1.3.2. Writing directly into to the source file.
-
- Option: TOUCH <# bytes>
-
- » This option is intended to convert only a small section at
- the beginning of a large file, without having to process the
- whole file. PARex will read the given number of bytes,
- process them, and write back the same amount of bytes!
-
- | ' PARex RAM:source TOUCH 500 REPL a BY b '
- | In this case PARex will read 500 bytes from the source
- | file, convert all a's to b's and write exactly 500
- | bytes back to the source file! This means, that all a's
- | in the first 500 bytes of the file will be b's now,
- | while the rest still remain a's.
-
-
-
-
- PARex v3.1x User Manual - Page 5
-
- » An example of the use of the TOUCH option can be found in
- the program script "AutoVERS". This script was written to
- install a header at the beginning of a source file
- (ModulaII, Oberon, C, Assembler, ARexx or AmigaDOS). Before
- each compilation of the source file, AutoVERS can then be
- called again to update the header.
-
- NOTE: PARex will always write the same amount of bytes back to
- the source file, as it has read in the first place!
-
- WARNING: only use this option if you really know what PARex is
- going to do!
-
- 1.3.3. Buffer sizing.
-
- Option: BUFFER <# bytes>
-
- » By default, PARex uses 4096 bytes for each buffer it needs.
- With this option one can enlarge the size of these buffers,
- as far as memory allows you to. If you're a harddisk user
- then this option really doesn't speed up processing.
-
- » If PARex can't allocate the desired size, then it will fall
- back to the default size of 4096 bytes.
-
- » The following buffers are affected :
- - the read buffer (stores source file; always present)
- - the write buffer (only used if replace commands are used)
- - the hexdump write buffer (only used if HEXDUMP is used)
- - the insert file buffer (only used if &FILE:& is used)
- - the context buffer (only used if CONTEXT is used)
-
- Option: [LOAD]
-
- » This option forces PARex to load the entire source file into
- memory, and thus to speed up the processing in case of large
- files. If memory doesn't allow this, then PARex will fall
- back on the default buffer size.
-
- NOTE: Using this option is recommended for floppy disk users,
- and certainly when wildcard searching is needed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 6
-
- 2. Global converting options.
-
- 2.1. Hexadecimal output.
-
- Option: HEXDUMP [<fmtstr>]
-
- » Using this option will result in a hexadecimal
- representation of the processed file. You can do everything
- as if HEXDUMP wasn't used, since PARex will only save the
- processed bytes in a hexadecimal text just before it saves
- them to the destination file.
-
- » If no format string is given, then the (default) hexadecimal
- output will look something like this:
-
- 00000000: E3100001 00000000 001B000F 004D0012 㤤¤¤¤¤¤¤¤¤¤¤M¤¤
- 00000010: 00060003 000107C6 DF0007C6 E1080000 ¤¤¤¤¤¤¤Æߤ¤Æᤤ¤
- 00000020: 00000000 00000000 00000000 00000001 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
- 00000030: 01180000 00000000 00000000 00170000 ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
- 00000040: 000707C6 98A00000 00000000 00000000 ¤¤¤Æ¤ ¤¤¤¤¤¤¤¤¤¤
- 00000050: 0015016A 003FFFFF 00000000 0200127F ¤¤¤j¤?ÿÿ¤¤¤¤¤¤¤
- 00000060: 0029AEF2 00000000 0026115C 00000000 ¤)®ò¤¤¤¤¤&¤\¤¤¤¤
- ...
-
- » One can change the format of this output by defining a
- formatstring, using the following codes:
-
- %Px : byte position, where x is the width [1..8]
-
- %Bx : byte value where 'x' is number of bytes on one line
- %Wx : word value where 'x' is number of words on one line
- %Lx : long value where 'x' is number of longwords on one
- line
-
- %Ax : ASCII text, where 'x' is the value of the character
- used to represent non-printable characters
-
- NOTE: the value 'x' can be given in decimal (can be
- introduced by "\d"), in hexadecimal (introduced with
- "\x") or in octal (introduced with "\o") notation!
-
- NOTE: the formatting codes are interpreted case-sensitive!
-
- » The used default format looks like : "%P8: %L4 %A\d164"
-
- » A format string like "%W5 \"%A\d186\" :%P4" would give the
- following output:
-
- E310 0001 0000 0000 001B "㺺ººººººº" :0000
- 000F 004D 0012 0006 0003 "ºººMºººººº" :000A
- 0001 07C6 DF00 07C6 E108 "ºººÆߺºÆáº" :0014
- 0000 0000 0000 0000 0000 "ºººººººººº" :001E
- 0000 0000 0000 0001 0118 "ºººººººººº" :0028
- 0000 0000 0000 0000 0000 "ºººººººººº" :0032
- 0017 0000 0007 07C6 98A0 "ºººººººÆº " :003C
- 0000 0000 0000 0000 0000 "ºººººººººº" :0046
- 0015 016A 003F FFFF 0000 "ºººjº?ÿÿºº" :0050
- ...
-
-
-
-
- PARex v3.1x User Manual - Page 7
-
- 2.2. Case conversion.
-
- The following two options affect all bytes saved to a file.
-
- Option: UCASE
-
- » This option will convert all bytes to upper case characters.
-
- Option: LCASE
-
- » This option will convert all bytes to lower case characters.
-
- WARNING: don't use these options on binary files, since not only
- text will be affected, but also the programming code!
-
-
- 2.3. Dynamic TAB to space replacing.
-
- Option: TAB <#>
-
- » One could replace TAB's by spaces in two ways. The first is
- to replace a TAB by a previously defined fixed number of
- spaces, e.g. replacing a TAB by 5 spaces. This method has
- one drawback, it doesn't take into account the number of
- characters since the last TAB or the last end-of-line code.
- The result of such replacing is that for example the
- columns of a table won't align correctly.
-
- | Suppose 'ram:file' has the following contents (a TAB is
- | represented by "->":
- | key->name
- | ===->====
- | a->Adrian
- | jo->John
-
- | Using ' PARex ram:file REPL \t BY " " will give
- | incorrect alignment:
- | key name
- | === ====
- | a Adrian
- | jo John
-
- The second method, which is selected by the TAB option, will
- replace a TAB with an appropriate number of spaces. The
- number given with the option indicates the size of a TAB in
- spaces. The minimal tabsize is 1. Using this option will for
- example correctly align the columns of a table, because the
- characters since the last TAB or end-of-line code are taken
- into account when replacing by spaces.
-
- | Using ' PARex ram:file TAB 5 ' will give correct
- | alignment of the columns:
- | key name
- | === ====
- | a Adrian
- | jo John
-
- » NOTE: the default AmigaDOS TAB-size is 8.
-
-
-
-
- PARex v3.1x User Manual - Page 8
-
- 3. Program information.
-
- 3.1. Before processing.
-
- Before PARex starts processing a file, it prints the following
- information :
-
- - name of the used PARex script (<none> if none used);
- - name of the used script mode(s) (<none> if none used);
- - 'GLOBAL' if the GLOBAL mode was also used;
- - number of replace commands used (0..x);
- - 'T' if the TAB option is used.
- - 'I' if a INIT command is used;
- - 'C' if a CLOSE command is used.
-
- Maybe this information seems a bit strange to you now, but later
- everything will become clear.
-
- 3.2. During processing.
-
- Option: TRACE
-
- » By default PARex doesn't output any information during
- processing of the source file. Using this option will force
- PARex to output how many percent of the source file already
- has been processed.
-
- TIP: using TRACE will keep your mind at rest, seeing that
- PARex is doing some heavy duty for you!
-
- NOTE: most of the program scripts supplied in the
- "ParexScripts" directory use the TRACE option.
-
- 3.3. After processing.
-
- After PARex has finished with processing the source file, the
- following information is given:
-
- - number of bytes used by the destination file;
- - number of replacements done on the file.
-
- Option: STAT
-
- » Users who want more detailed information can use this
- option. The following information is then given:
-
- * General info:
- - number of ticks and seconds PARex needed;
- - size of the source and the destination file, as well
- as the difference between the two sizes.
-
- * Command info:
- - number of REPL commands used, and percentage of the
- total number of replacements;
- - number of STRIP commands used, and percentage of total;
- - number of CAP commands used, and percentage of total;
- - number of DECAP commands used, and percentage of total;
- - number of replaced TAB's by the TAB option.
-
-
-
-
- PARex v3.1x User Manual - Page 9
-
- * Variable info:
- - number of &FILE& variables used;
- - number of &TIME& variables used;
- - number of &SRCPATH& variables used;
- - number of &SRCNAME& variables used;
- - number of &DSTPATH& variables used;
- - number of &DSTNAME& variables used.
-
- 3.4. Suppressing information.
-
- Option: NOVERSION
-
- » Suppresses the output of the programs copyright and version
- prompt.
-
- Option: SILENT
-
- » All program messages are suppressed when this option is
- selected. In other words, TRACE or STAT won't work.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 10
-
- 4. Main replace commands.
-
- Currently PARex supports several replace commands. But before we
- start with explaining them some words on used terms:
-
- - main command: refers to the following replace commands: INIT,
- CLOSE, REPL, STRIP, CAP, DECAP.
- As many of these commands can be used on the
- command line as AmigaDOS allows. If you need to
- use many commands than it's better to create a
- PARex script, which may contain as many as you
- need. When no replace commands are used, then
- PARex will just copy the source file!
-
- NOTE: the order in which you enter different
- replace commands is important, since PARex
- will always start searching with the first
- one, then the second, and so on. The
- replace commands entered on the command
- line, are used before the ones in the data
- scripts! In other words, first found is
- first served! This hierarchy doesn't apply
- to INIT and CLOSE.
-
- - sub command : a command that can only be used in relation with
- a main command. A sub-command redirects the
- working of the main command. These commands are
- explained throughout this manual.
-
- NOTE: as a general rule, always enclose the
- main-command and its sub-commands between
- curly brackets ("{" & "}") if you use
- them on the command line.
-
- - searchStr : the string (text or other) PARex has to find.
-
- - replStr : the string which comes in the place of the
- searchStr. The replStr can also be an empty
- string, which is then defined as ' "" '!
-
- When describing the main commands, examples will be given where
- the searchStr and/or the replStr will contain strange codes. These
- codes are later explained in point 4.7.
-
- 4.1. INIT : inserting a string at the beginning of a file.
-
- Command: INIT <str>
-
- » This command will put the <str> at the very beginning of the
- destination file. Only when this string has been written
- will PARex commence with the actual processing of the source
- file.
-
- | ' PARex ram:source INIT "I will be the first line!" '
- | The ram:source.prx (destination) file will be the same
- | as the source file, except that the given string will be
- | the first line.
-
- NOTE: this command is only used once!
-
-
-
- PARex v3.1x User Manual - Page 11
-
- WARNING: when this command is used on the command line, then
- any such commands in a used data script are ignored.
-
- Sub-cmds: [CAP|DECAP] [MINSIZE <# bytes>] [MAXSIZE <# bytes>]
- [LEFTFILL|RIGHTFILL <0..255>]
-
- 4.2. CLOSE : adding a string to the end of a file.
-
- Command: CLOSE <str>
-
- » This command will append the <str> at the end of the
- destination file. Thus only after PARex has finished with
- the source file, will this string be written.
-
- | ' PARex ram:source PRT CLOSE \f '
- | After the source file has been send to the printed, a
- | page-eject code will be send.
-
- NOTE: this command is only used once!
-
- WARNING: when this command is used on the command line, then
- any such commands in a used data script are ignored.
-
- Sub-cmds: [CAP|DECAP] [MINSIZE <# bytes>] [MAXSIZE <# bytes>]
- [LEFTFILL|RIGHTFILL <0..255>]
-
- 4.3. REPL : replacing one string by another.
-
- Command: REPL <str> BY <str>
-
- » This command searches for the first <str>, and if found,
- replaces it with the second <str>.
-
- | ' PARex ram:source REPL hello BY hi '
- | All "hello" strings will be replaced by hi. Note that
- | "hello" is search non-case sensitive here. If you only
- | want to replace "hello" and not "HeLLo" for example,
- | then use the CASECHECK option.
-
- Sub-cmds: [OR <str> WHEN <name>] [WILD] [WORD] [CONTEXT]
- [TIMES <#>] [EVERY <#>] [AFTER <#>] [CASE] [NOCASE]
- [FIXCASE] [CAP|DECAP] [FIT] [ZERO]
- [MINSIZE <# bytes>] [MAXSIZE <# bytes>]
- [LEFTFILL|RIGHTFILL <0..255>]
-
- Sub-cmd: OR <str> WHEN <name>
-
- » This sub-command is only of use when the REPL is used in a
- script (see chapter 7 on the use of scripts). It enables us
- to define two replStr's. The second replStr, which is the
- <str> after the OR keyword, will only be used (instead of
- the first <str>), if the name given with the WHEN (command
- line) option, matches the WHEN name of this sub-command.
-
- Look at the program format again, which was printed at the
- beginning of this manual. There you'll see the following
- option: [WHEN <name|pattern>]. It's with this option that we
- can decide if we're going to use the second replStr. We do
- this by entering a name, or a pattern. This name is then
- compared with the name given in the WHEN sub-command. If
-
-
- PARex v3.1x User Manual - Page 12
-
- they match then the second replStr is used, if not, the
- first is used.
-
- | ' REPL hello BY hi OR bye WHEN quit '
- | If we just use ' PARex ram:source ' then "hello" will be
- | replace by "hi".
- | But if we use ' PARex ram:source WHEN quit ', then
- | "hello" will be replaced by "bye" and not by "hi"!
-
- NOTE: only the WHEN option name may be a pattern, not the name
- in the sub-command!
-
- 4.4. STRIP : removing characters between two strings.
-
- Command: STRIP [+|-]<str> TO [+|-]<str>
-
- » This command is used to discard all characters between the
- two given strings, including the strings themselves. The
- most common use for this command is the stripping of
- comments in source files. Note that both string arguments of
- the STRIP command are searchstrings.
-
- | ' PARex ram:source { STRIP /* TO */ } '
- | This will remove all C-comments from the ram:source
- | file. Note that this doesn't catch nested comments, and
- | can therefore result in stripping non-comment text! But
- | a sub-command is provided to solve this problem!
-
- » If you don't want to strip the searchstrings themselves then
- you must type a minus sign (-) before the searchstring.
-
- | ' STRIP -/* TO */ ' will strip the text between "/*" and
- | "*/", including the last "*/" string. The first string
- | "/*" isn't stripped!
-
- If a searchStr should begin with a minus sign, then you must
- type a minus sign (-) first if you want to keep the
- searchStr after stripping, or a plus sign (+) if you don't
- want to keep it.
-
- | ' STRIP +-[ TO --] ' The first string "-[" will be
- | stripped, but the second string "-]" will be kept.
-
- Sub-cmds: [NEST] [WILD] [WORD] [TIMES <#>] [EVERY <#>]
- [AFTER <#>] [CASE] [NOCASE] [FIXCASE] [CAP|DECAP]
-
- Sub-cmd: NEST
-
- » As mentioned earlier, the bare STRIP command doesn't account
- for nested comments. Some languages don't allow nested
- comments, such as assemblers or even AmigaDOS. Here all text
- after the semi-colon (";") upto the end-of-line character is
- regarded as a comment. But most programming languages allow
- nested comments. The NEST sub-command is used to strip
- nested comments from source files, without harming the
- actual source.
-
- | ' PARex ram:source { STRIP /* TO */ NEST } '
- | Does the same as the previous example, but now without
- | the risque of losing valuable source code.
-
-
- PARex v3.1x User Manual - Page 13
-
- RULE: if a programming language allows nested comments, then
- always use the NEST sub-command! This is the case with
- ModulaII, Oberon, C and even ARexx scripts.
-
- 4.5. CAP : putting found string in upper case.
-
- Command: CAP <str>
-
- » This command will put the found searchStr in upper case
- characters.
-
- | ' PARex ram:source LOAD { CAP p#?x WILD } '
- | This will put all text which matches the "p#?x" pattern
- | in upper case.
-
- Sub-cmds: [WILD] [WORD] [TIMES <#>] [EVERY <#>] [AFTER <#>]
- [CASE] [NOCASE] [FIXCASE]
-
- 4.6. DECAP : putting found string in lower case.
-
- Command: DECAP <str>
-
- » This command will put the found searchStr in upper case
- characters.
-
- | ' PARex ram:source LOAD { CAP p#?x WILD } '
- | This will put all text which matches the "p#?x" pattern
- | in upper case.
-
- Sub-cmds: [WILD] [WORD] [TIMES <#>] [EVERY <#>] [AFTER <#>]
- [CASE] [NOCASE] [FIXCASE]
-
- 4.7. Formatting of the searchStr and replStr.
-
- » Always enclose the string between double quotation marks if it
- contains spaces, or if it begins with a semi-colon!
-
- | "Hello there"
- | If no quotation marks would be used, then PARex will see two
- | strings, instead of one.
-
- » In some cases the datastring will have to contain double
- quotation marks. In order to introduce such a double quotation
- mark in your datastring you must enter a backslash followed by
- the quotation mark (\").
-
- | REPL \e[2\"z BY NLQ_on
- | This command will search for the nlq printer control
- | sequence ( ESC[2"z ) and replace it with "NLQ_on" if found.
-
- » Besides the double quotation mark PARex supports other special
- characters (they're all introduced by a backslash '\') :
-
- \0 : null
- \e : ESCape
- \n : new line
- \t : horizontal tab
- \v : vertical tab
- \f : form feed
- \r : return
-
-
- PARex v3.1x User Manual - Page 14
-
- \b : backspace
- \" : double quotation mark
- \\ : backslash
- \& : ampersand
-
- » All the CTRL-codes in the ASCII range 0..31 are also
- supported. Below is a table of the codes and their name :
-
- CODE CHARACTER DEC DESCRIPTION
- ---- ---------- --- -----------
- \c@ CTRL-@ 0 NUL (null)
- \cA CTRL-A 1 SOH (start of heading)
- \cB CTRL-B 2 STX (start of text)
- \cC CTRL-C 3 ETX (end of text; break)
- \cD CTRL-D 4 EOT (end of transmission)
- \cE CTRL-E 5 ENQ (enquiry)
- \cF CTRL-F 6 ACK (acknowledge)
- \cG CTRL-G 7 BEL (beep)
- \cH CTRL-H 8 BS (backspace)
- \cI CTRL-I 9 HT (horizontal tabulation)
- \cJ CTRL-J 10 LF (line feed)
- \cK CTRL-K 11 VT (vertical tabulation)
- \cL CTRL-L 12 FF (form feed)
- \cM CTRL-M 13 CR (carriage return)
- \cN CTRL-N 14 SO (shift out)
- \cO CTRL-O 15 SI (shift in)
- \cP CTRL-P 16 DLE (data link escape)
- \cQ CTRL-Q 17 DC1 (device control 1 or X-ON)
- \cR CTRL-R 18 DC2 (device control 2)
- \cS CTRL-S 19 DC3 (device control 3 or X-OFF)
- \cT CTRL-T 20 DC4 (device control 4)
- \cU CTRL-U 21 NAK (negative acknowledge)
- \cV CTRL-V 22 SYN (synchronous idle)
- \cW CTRL-W 23 ETB (end of transmission block)
- \cX CTRL-X 24 CAN (cancel)
- \cY CTRL-Y 25 EM (end of medium)
- \cZ CTRL-Z 26 SUB (substitute)
- \c[ CTRL-[ 27 ESC (escape)
- \c\ CTRL-\ 28 FS (file separator)
- \c] CTRL-] 29 GS (group separator)
- \c^ CTRL-^ 30 RS (record separator)
- \c_ CTRL-_ 31 US (unit separator)
-
- » All ASCII-codes [0..255] can also be inserted by using their
- ASCII value. This value can be in decimal, octal or
- hexadecimal. To introduce an ASCII value you must us the
- following :
-
- \d# : decimal value, where # is a number in the 0..255 range.
- The value can have no more than 3 characters.
- \o# : octal value, where # is a number in the 0..377 range.
- The value can no more than 3 characters.
- \x# : hexadecimal value, where # is a number in the 0..FF
- range. The value can have no more than 2 characters.
-
- NOTE: preceding zeros aren't needed, unless PARex could
- interprete a character of the string as part of the
- number. If this is the case then your value must have the
- maximum character width.
-
-
-
- PARex v3.1x User Manual - Page 15
-
- | '\d94 wheels' -> interpreted as '^ wheels' ('^' has
- | ASCII-value 94)
- | '\d0094 wheels' -> interpreted as TAB+'4 wheels' (TAB
- | has ASCII-value 9)
-
- » Strings for binary files
-
- When processing binary files, like programs,..., most strings
- are C-strings. This means that at the end of the string a NULL
- character (ASCII 0) is found. The strings aren't C-strings,
- since plain text files don't include NULL codes.
-
- In order to make sure that the replace string is NULL
- terminated, you must include such a code when defining the
- string. (Assuming that the search string is also NULL
- terminated.)
-
- | Assume we are processing a program, and at a certain time
- | it prints "string".
- | 'REPL string BY STR' -> the program will print "STRing",
- | which wasn't our intention.
- | 'REPL string BY STR\o' -> now the program will print
- | "STR" ('\o' inserts a NULL code).
-
- Suppose the string to search is found two times in the file,
- once NULL terminated and once not. If you only want to replace
- the NULL terminated one, then you must also include a NULL code
- when defining your search string.
-
- | Assume we have two strings in a program : "string\o" and
- | "this string of \o"
- | 'REPL string\o BY STR\o' -> after replacing we will have
- | "STR\o" and "this string of\o"
- | 'REPL string BY STR\o' -> after replacing we will have
- | "STR\o" and "this STR\o"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 16
-
- 5. Search control.
-
- 5.1. Case-sensitive searching.
-
- Option: CASECHECK
-
- » By default, PARex uses a non-case sensitive search. Using
- this option forces the program to search case-sensitive.
- This option has effect on all main commands!
-
- | default : "hello" = "HeLLo", "heLLO", "HELLO", ...
- | CASECHECK: "hello" only equals "hello"
-
- NOTE: in previous versions, this option was called 'CASE'!
-
- Sub-cmd: CASE
-
- » With this sub-command you can make a main-command to search
- case-sensitive. All other main-commands won't be affected by
- this.
-
- | 'PARex ram:src { REPL aa BY bb CASE } { REPL cc BY dd }'
- | This will replace two strings, the first string (aa) is
- | searched case-sensitive, while the second string (cc) is
- | searched non-case-sensitive!
-
- Sub-cmd: NOCASE
-
- » The same as CASE, but now to make the main-command search
- non-case sensitive.
-
- NOTE: using the CASECHECK option, which works on all main-
- commands, will override this sub-command!
-
- Sub-cmd: FIXCASE
-
- » Using program options, such as CASECHECK, can override the
- effect of CASE and NOCASE sub-commands. To prevent this from
- happening, you must use the FIXCASE sub-command.
-
- | { REPL aa BY bb NOCASE } : searches non-case sensitive.
- | If you would use CASECHECK, then PARex would start to
- | search case-sensitive again. Using FIXCASE will make
- | sure that PARex keeps searching non-case sensitive with
- | this command: { REPL aa BY bb NOCASE FIXCASE }.
-
- 5.2. Wildcard searching.
-
- Sub-cmd: WILD
-
- » By default PARex will interprete the searchStr literally. In
- some cases, it's more useful to search with wildcards. The
- following wildcards are supported by PARex:
-
- - "#" : the character following occurs none or more times.
- - "?" : represents one character.
- - "*" : this is the true wildcard, and is equal to "#?".
- Note that if you use "#?", PARex will translate it
- into "*".
- - "'" : interprete the character following as a normal
-
-
- PARex v3.1x User Manual - Page 17
-
- character, and not as a wildcard character.
- - "|" : allows defining of several patterns in one string.
-
- !! » In order for a main-command to use these wildcards, you must
- add the sub-command WILD to it, else the wildcards would be
- interpreted as normal characters.
-
- | ' PARex ram:src { REPL h#?o BY hi WILD } '
- | Will replace all strings that fall under the pattern
- | "h#?o". So "hello", "ho" or "help me to" would be
- | replaced by "hi".
-
- WARNING: when doing wildcard searching, it's recommended to use
- the LOAD option, especially with "#?" or "*" wildcards
- since these can otherwise give wrong results.
-
- NOTE: you can use the supplied WildPARex program to experiment
- with the use of wildcards.
-
- Usage: REPL <STR> BY <str> / STRIP <STR> TO <STR>
- CAP <STR> / DECAP <STR>
-
- 5.3. Context remembering.
-
- Sub-cmd: CONTEXT
-
- » In some cases it could be interesting to save some
- characters which fall under the searchStr, in order to use
- them again in the replStr. The CONTEXT sub-command makes
- this reality. Worth mentioning is the fact that this sub-
- command will automatically set the WILD sub-command too.
-
- » Upto twenty contexts can be remembered, for a total of upto
- 4096 bytes. When the BUFFER option was used, then this
- buffer will also be enlarged.
-
- » The following codes are used to define a context in the
- searchStr :
- - the opening curly bracket ("{") to open a context;
- - the closing curly bracket ("}") to close a context.
- All characters that fall between these curly brackets will
- be remembered.
-
- | ' h{#?}o ' would remember "ell" if "hello" was found,
- | or "elp this t" when "help this to" was found...
-
- Any wildcards or characters can be used between these
- context codes. An empty context like "{}" is translated to
- "{#?}" by PARex.
-
- | Some examples: {p#?x}, p{#A??}x, pa{#?#x}, p{}x, ...
-
- » To insert the saved characters in the replStr, you type the
- two curly brackets at the desired place, thus "{}". Every
- "{}" in the replStr corresponds to the defined context in
- the searchStr. Thus the second "{}" in the replStr will
- insert the characters which were saved in the second context
- of the searchStr.
-
- | the replStr "H{}I" would be like "HellI" if "ell" was
-
-
- PARex v3.1x User Manual - Page 18
-
- | remembered, and like "Help this tI" if "elp this t" was
- | remembered...
-
- | ' PARex ram:src { REPL "PROCEDURE {#?}\n" BY "ROUTINE
- | {}\n ' would convert "PROCEDURE Print(str: ARRAY OF
- | CHAR)\n" TO "ROUTINE Print(str: ARRAY OF CHAR)\n"; ...
-
- » If you want to insert a curly bracket as a normal text
- character, and not as a context code, you must preceed it by
- the literal wildcard code "'"!
-
- Usage: REPL <STR> BY <str> / STRIP <STR> TO <STR>
- CAP <STR> / DECAP <STR>
-
- 5.4. Word-only searching.
-
- Sub-cmd: WORD
-
- » By default PARex will just search for a string, regardless
- if this string is a word or part of a word. In some cases
- only words may be replaced. To make sure that PARex only
- finds words, you must use the WORD sub-command.
-
- | ' { REPL hi BY hello WORD } '; this main-command is
- | only executed if "hi" is found as a word, and not as
- | part of a word. Thus "ships" won't do, but " hi " will.
-
- » A string is regarded as a word, if the ASCII value of the
- character before the string, and the ASCII value of the
- character after the string fall in one of the following
- ranges :
-
- - 0..47
- - 58..63
- - 91..96
- - 123..191
-
- Usage: REPL <STR> BY <str> / STRIP <STR> TO <STR>
- CAP <STR> / DECAP <STR>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 19
-
- 6. Program variables.
-
- » As of version 3 some variables are supported. These variables
- can be anywhere in the searchStr or replStr. They can be divided
- in two types : fixed variables and volatile variables. While
- fixed variables can be used in both the searchStr and the
- replStr, volatile variables are only allowed in the replStr.
-
- Fixed variables are variables where the value is defined before
- the source file is processed, while the value of volatile
- variables is only known at the time of replacing the searchStr
- by the replStr.
-
- These variables are inserted in the searchStr or the replStr
- between two "&" characters. Everything between such ampersand
- characters is regarded as being part of the variable.
-
- NOTE: if you want to insert "&" characters as normal text, then
- you must use "\&".
-
- » These variables can be used in all the main commands, so with
- INIT, CLOSE, REPL, STRIP, CAP and DECAP!
-
- » The strings in which you can use a variable, are accented in
- bold text in the "Usage:" line.
-
- 6.1. PARex information.
-
- Variable: &NAME&
-
- » Inserts the name of the program (thus "PARex"), in the
- string.
-
- | ' PARex ram:source REPL ">&NAME&<" BY "xeRAP" '
- | Replaces all ">PARex<" strings in the source file by
- | "xeRAP".
-
- Variable: &VERSION&
-
- » Inserts the version of PARex in the string.
-
- | ' PARex ram:source REPL "v&VERSION&" BY "V=&VERSION&" '
- | Replaces all "v3.00" strings in the source file by
- | "v=3.00".
-
- Usage: INIT <STR> / CLOSE <STR> / CAP <STR> / DECAP <STR>
- REPL <STR> BY <STR> OR <STR> / STRIP <STR> TO <STR>
-
- 6.2. Inserting files.
-
- Variable: &FILE:<name>&
-
- » With this variable you can insert a file in the desired
- place in the string. You can use as many &FILE:& variables
- in a string as you want. The name of the file to insert is
- given directly after the colon. No double quotation marks
- have to be used if the filename should include spaces, but
- remember to enclose the entire string between double
- quotation marks!
-
-
-
- PARex v3.1x User Manual - Page 20
-
- » This variable can for example be used to insert the value of
- environment variables!
-
- | SETENV test xerap
- | ' PARex ram:src REPL parex BY file->&FILE:env:test& '
- | This will replace all "parex" strings in the ram:src
- | file with "file->xerap".
-
- WARNING: if the file can't be found then "<file not found>" is
- inserted in the string instead.
-
- Usage: INIT <STR> / CLOSE <STR> / REPL <str> BY <STR> OR <STR>
-
- 6.3. Inserting date and time.
-
- Variable: &FIXTIME:[<formatstr>]&
-
- » This variable will insert the time, where the used time is
- the one at program startup. If no format string is given,
- then the default AmigaDOS format (dd-mmm-yy hh:mm:ss) is
- used.
-
- | ' PARex ram:source REPL parex BY date=&FIXTIME:& '
- | All "parex" strings in the ram:source file will be
- | replaced by e.g. "date=20-Nov-93 22:43:42"
-
- » The following format codes can be used to construct a custom
- formatted timestring:
-
- DATE CODES : %w -> a two character day name ('Mo'..'Su')
- %W -> the full day name ('Monday'..'Sunday')
- %d -> two digit day in month (00..31)
- %m -> two digit month (01..12)
- %M -> short month name ('Jan'..'Dec')
- %O -> full month name ('Januray'..'December')
- %y -> two digit year (e.g. '93')
- %Y -> four digit year (e.g. '1998')
-
- TIME CODES : %h -> hours in 12 hour mode (00..11)
- %H -> hours in 24 hour mode (00..23)
- %i -> minutes (00..59)
- %s -> seconds (00..59)
- %T -> 'AM' or 'PM'
-
- DATESTAMP : %D -> days since 1-jan-78
- %U -> minutes since 00:00:00
- %I -> ticks since last minute
-
- | 'PARex ram:src REPL prx BY "date=&FIXTIME:%W, %d %O %Y&"
- | All "parex" strings in the ram:source file will be
- | replaced by e.g. "date=Saturday, 20 November 1993".
-
- NOTE: these format codes are interpreted case-sensitive!
-
- Usage: INIT <STR> / CLOSE <STR> / CAP <STR> / DECAP <STR>
- REPL <STR> BY <STR> OR <STR> / STRIP <STR> TO <STR>
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 21
-
- Variable: &TIME:[<formatstr>]&
-
- » The same as &FIXTIME:&, but now the time used is the one at
- the moment the string is used!
-
- Usage: INIT <STR> / CLOSE <STR> / REPL <str> BY <STR> OR <STR>
-
- 6.4. Inserting path and name of source & destination file.
-
- Variable: &SRCPATH& and &SRCNAME&
-
- » Inserts the path and/or name of the source file in the
- string.
-
- | ' PARex RAM:source PRT INIT \e[1m&SRCNAME&\e[0m\n\n '
- | This will send ram:source to the printer, where first a
- | line in bold text is printed with the name of the file
- | to print.
-
- Variable: &DSTPATH& and &DSTNAME&
-
- » Inserts the path and/or name of the destination file in the
- string.
-
- | 'PARex ram:src TO ram:dest INIT &DSTPATH&->&DSTNAME&\n'
- | This will copy ram:src to ram:dest, where the first line
- | of the ram:dest file will be "ram:->dest".
-
- Usage: INIT <STR> / CLOSE <STR> / REPL <str> BY <STR> OR <STR>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 22
-
- 7. Using PARex data scripts.
-
- Using the main-commands on the command line has its limitations.
- For example, using one or two main-commands gives now problems,
- but suppose you'll need to use more than twenty commands! Then
- it's better to put these main-commands in a script.
-
- 7.1. Setting up scripts.
-
- » PARex scripts, like AmigaDOS scripts, are plain text files,
- that can be created and edited with any texteditor.
-
- » A comment is inserted in the same way as with AmigaDOS
- scripts. Thus everything after a semi-colon upto the end of
- the line is regarded as the comment. You may type comments
- on the same line as the command.
-
- | ' REPL aa BY bb ; this is the comment '
-
- » Only one main-command (including all its sub-commands) can
- be typed on a line.
-
- | REPL a#?a BY bb OR cc WHEN name CASE WILD
-
- » You can type them on several lines by using curly
- brackets, just as you do on the command line. In this case
- everything after an opening curly bracket upto the closing
- curly bracket is regarded as being part of the main-
- command. There's one limitation, when a command needs an
- argument, then both the keyword and the argument must be on
- the same line!
-
- | ' { REPL aa BY bb ; comments are allowed here
- | OR cc WHEN name ; another comment
- | CASE
- | CAP } ' ; even here!
-
- 7.2. Script commands.
-
- If needed, you can divide your data script in blocks, which can
- then be selected later from the PARex program. The following
- commands allow you to do this.
-
- Command: GLOBAL
-
- » This block of replace commands will be used when you use the
- following options at program startup : GLOBAL or ALL. The
- end of the block is reached when a the MODE or a EXITPXS
- command is found.
-
- » A GLOBAL block can only be defined once in a script!
-
- Command: MODE <name>
-
- » This command also defines a block of replace commands, but
- now the block is named. As many MODE commands can be used as
- needed. Such a block can only be selected with the MODE
- (command line) option at program startup. The name (or a
- pattern) given with the MODE option at program startup is
- used to search for the corresponding MODE block in the
-
-
- PARex v3.1x User Manual - Page 23
-
- script.
-
- | Suppose we have the following script :
- | ' MODE test
- | REPL aa BY bb
- | REPL cc BY dd
- | MODE text
- | REPL oo BY pp
- | REPL uu BY vv '
- | Using ' PARex ram:source MODE text ' will convert the
- | source file with "REPL oo BY pp" and "REPL uu BY vv".
- | Using ' PARex ram:source MODE te?t ' would use both
- | MODEs since the pattern name "te?t" matches both "test"
- | and "text".
-
- » As with the GLOBAL command, the block is ended by another
- MODE command, a GLOBAL command or a EXITPXS command.
-
- Command: EXITPXS
-
- » This command informs PARex that it can stop scanning the
- script. This means that everything after this command is
- ignored by PARex, provided the block of replace commands
- where EXITPXS belongs to is used.
-
- | Suppose we have the following script :
- | ' MODE test
- | REPL aa BY bb
- | REPL cc BY dd
- | EXITPXS
- | MODE text
- | REPL oo BY pp
- | REPL uu BY vv
- | EXITPXS '
- | Using ' PARex ram:source MODE text ' would only use the
- | "text" mode. The first EXITPXS has no effect since PARex
- | wasn't reading that block of replace commands! The
- | second EXITPXS had effect since its block was read.
-
- 7.3. Script options.
-
- Option: SCRIPT <file[.pxs]>
-
- » Uses the named script file. It's not needed to add the
- ".pxs" suffix, since PARex will do this for you if it
- couldn't open the file under the given name.
-
- Option: NOSCRIPT
-
- » Forces PARex not to open a scriptfile. Primarily used in
- earlier versions of PARex to disable the default
- "S:PARex.pxs" script usage.
-
- Option: GLOBAL
-
- » Selects the GLOBAL block of a script.
-
- » If no script file was specified, then the default
- "S:PARex.pxs" is used (if present).
-
-
-
- PARex v3.1x User Manual - Page 24
-
- Option: MODE <name|pattern>
-
- » Selects the named MODE block(s). As mentioned above, the
- name can be a pattern.
-
- » If no script file was specified, then the default
- "S:PARex.pxs" is used (if present).
-
- Option: ALL
-
- » Selects all replace commands in a scripts, thus ignoring the
- MODE and GLOBAL script commands. But the EXITPXS is still
- recognised!
-
- » If no script file was specified, then the default
- "S:PARex.pxs" is used (if present).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 25
-
- 8. Additional sub-commands.
-
- In this chapter the rest of the sub-commands are explained. They
- give more control over the searching and over the replStr.
- Remember that a sub-command only affects one main-command, except
- when they're being used as a global working (command line) option.
- The latter is explained in point 8.5.
-
- 8.1. Limit replacing.
-
- By default PARex will replace every string that matches a
- searchStr. The following sub-commands can alter this. In the
- example "N" (no replace) and "Y" (replace) are used to explain the
- function. These sub-commands are supported by REPL, STRIP, CAP and
- DECAP.
-
- Sub-cmd: TIMES <#>
-
- » The searchStr will only be used the given number of times.
-
- | ' REPL hello BY hi TIMES 5 ' -> Y Y Y Y Y N N N...
-
- Sub-cmd: EVERY <#>
-
- » The searchStr will only be replaced every 'x'th occurence.
-
- | ' REPL hello BY hi EVERY 2 ' -> N Y N Y N Y...
-
- Sub-cmd: AFTER <#>
-
- » Only replace the searchStr after the 'x'th occurence.
-
- | ' REPL hello BY hi AFTER 3 TIMES 2 ' -> N N N Y Y N...
-
- 8.2. Defining the size of the replace string.
-
- The size of the string that replaces the searchStr can also be
- altered.
-
- » The following sub-commands relate the size of the replStr to the
- size of the searchStr. These commands are useful when working on
- binary files, where you don't want to insert a string larger
- than the searchStr, since this can have disasterous effects.
- They're only supported with the REPL command.
-
- Sub-cmd: FIT
-
- » This command makes sure that the length of the replStr is
- not longer than the found string to replace. If the replStr
- is shorter, then nothing is done.
-
- | ' REPL hi BY hello FIT ' will replace "hi" by "he", not
- | "hello", since it's too long.
-
- Sub-cmd: ZERO
-
- » This command makes sure that the length of the replStr is
- as long as the found string to replace. Should the replStr
- be shorter, then it's appended with ASCII NULL codes (or the
- code defined with LEFTFILL or RIGHTFILL). If the replStr is
-
-
- PARex v3.1x User Manual - Page 26
-
- longer, than nothing is done.
-
- | ' REPL hello BY hi ZERO ' will replace "hello" by
- | "hi\o\o\o" (note that "\o' is used here to represent the
- | NULL code).
-
- TIP: if working on binary files, always use FIT and ZERO to play
- safe!
-
- The following two sub-commands define directly the size of the
- replStr. Here the size is directly defined, and thus not related
- to the searchStr! These commands won't work when FIT or ZERO is
- used! These sub-commands are supported with INIT, CLOSE and REPL.
-
- Sub-cmd: MINSIZE <# bytes>
-
- » Defines that the replStr must hold at least the given number
- of bytes. If this isn't the case, then the replStr will
- appended with ASCII NULL codes (or the code defined with
- LEFTFILL or RIGHTFILL). Should the string be longer, then
- nothing is done.
-
- | ' REPL hello BY hi MINSIZE 4 ' will replace "hello" by
- | "hi\o\o" (note that "\o' is used here to represent the
- | NULL code).
-
- Sub-cmd: MAXSIZE <# bytes>
-
- » Defines the maximum size that the replStr may have. If it's
- longer then only the given number of bytes are used, the
- rest is ignored. Should the replStr be shorter, then nothing
- is done.
-
- | ' REPL hi BY hello MAXSIZE 3 ' will replace "hi" by
- | "hel".
-
- The following two sub-commands define if we need to insert
- characters at the beginning of the replStr, or at the end of it.
- The code used for inserting or appending is also defined with
- these commands. These commands are supported with INIT, CLOSE and
- REPL.
-
- Sub-cmd: LEFTFILL|RIGHTFILL <0..255>
-
- » If the replStr needs to be appended (in case of ZERO or
- MINSIZE) then by default PARex appends at the end of the
- string with ASCII NULL codes. These commands can change
- this. The code to append with must be given as a value
- between 0 and 255. This value can be given in decimal (can
- be introduced with \d), in hexadecimal (introduced with \x)
- or in octal (introduced with \o).
-
- » LEFTFILL will lengthen the replStr by inserting the needed
- bytes at the beginning, while RIGHTFILL will do this at the
- end of the string.
-
- | ' REPL hello BY hi MINSIZE 5 LEFTFILL \d64' will replace
- | "hello" by "@@@hi"
-
-
-
-
- PARex v3.1x User Manual - Page 27
-
- WARNING: the LEFTFILL sub-command doesn't work when the
- HEXDUMP option is used!
-
- 8.3. Case conversion.
-
- The following sub-commands are supported by REPL, STRIP, INIT and
- CLOSE.
-
- Sub-cmd: CAP|DECAP
-
- » Will put all text of the replStr (including all bytes which
- come from the program variables) into upper case (with CAP)
- or into lower case (with DECAP) characters.
-
- | ' REPL aa BY hi CAP ' will replace "hello" by "HI"
-
- | ' REPL aa BY HI DECAP ' will replace "hello" by "hi"
-
- 8.4. Making sub-commands to work on all main-commands.
-
- » In some cases you'll want to make a sub-command effective on
- all used main-commands. To do this, you must enter the sub-
- command as a program (command line) option, and before any
- main-command!
-
- » In order to be sure that a sub-command is interpreted as a
- global working option, then it's best to place a main-
- command (if used on the command line) between curly
- brackets.
-
- | ' PARex ram:src TIMES 2 { REPL aa BY bb TIMES 5 } '
- | You'll see that TIMES is used twice, but the second
- | TIMES sub-command is ignored, since the first (TIME 2)
- | one works globally!
-
- » The following sub-commands can be made to work globally:
- CAP, DECAP, WILD, CONTEXT, NEST, FIT, ZERO, MINSIZE,
- MAXSIZE, LEFTFILL, RIGHTFILL, TIME, EVERY, AFTER and WORD.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 28
-
- A. Option reference.
-
- ALL ....................................................... 25
- AFTER <#> ............................................. 26, 28
- BUFFER <# bytes> .......................................... 6
- CAP ....................................................... 28
- CASECHECK ................................................. 17
- CONTEXT ............................................... 18, 28
- CONVERT ................................................... 5
- DECAP ..................................................... 28
- EVERY <#> ............................................. 26, 28
- FIT ................................................... 26, 28
- [FROM] <file|dir|pattern> ................................. 4
- GLOBAL .................................................... 24
- HEXDUMP [<fmtstr>] ........................................ 7
- LCASE ..................................................... 8
- LEFTFILL <0.255> ...................................... 27, 28
- LOAD ................................................... 6, 18
- MAXSIZE <# bytes> ..................................... 27, 28
- MINSIZE <# bytes> ..................................... 27, 28
- MODE <name|pattern]> .................................. 23, 25
- NEST .................................................. 13, 28
- NOSCRIPT .................................................. 24
- NOVERSION ................................................. 10
- PAR ....................................................... 5
- PRT ....................................................... 5
- READ <# bytes> ............................................ 5
- RIGHTFILL <0.255> ..................................... 27, 28
- SCRIPT <file[.pxs]> ....................................... 24
- SER ....................................................... 5
- SILENT .................................................... 10
- STAT ...................................................... 9
- TAB <#> ................................................... 8
- TIMES <#> ............................................. 26, 28
- [TO] <file|dir> ........................................... 4
- TOUCH <# bytes> ........................................... 5
- TRACE ..................................................... 9
- UCASE ..................................................... 8
- WHEN <name|pattern> ....................................... 12
- WILD .............................................. 17, 18, 28
- WORD .................................................. 19, 28
- ZERO .................................................. 26, 28
-
- [{] CAP <str> [<cmds> }] ................................ 14
- [{] CLOSE <str> [<cmds> }] ................................ 12
- [{] DECAP <str> [<cmds> }] ................................ 14
- [{] INIT <str> [<cmds> }] ................................ 11
- [{] REPL <str> BY <str> [<cmds> }] ....................... 12
- [{] STRIP [+|-]<str> TO [+|-]<str> [<cmds> }] ............. 13
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 29
-
- B. Command reference.
-
- B.1. Main commands.
-
- CAP <str> ................................................. 14
- [WILD] [WORD] [TIMES <#>] [EVERY <#>] [AFTER <#>]
- [CASE] [NOCASE] [FIXCASE]
-
- CLOSE <str> ............................................... 12
- [CAP|DECAP] [MINSIZE <# bytes>] [MAXSIZE <# bytes>]
- [LEFTFILL|RIGHTFILL <0..255>]
-
- DECAP <str> ............................................... 14
- [WILD] [WORD] [TIMES <#>] [EVERY <#>] [AFTER <#>]
- [CASE] [NOCASE] [FIXCASE]
-
- INIT <str> ................................................ 11
- [CAP|DECAP] [MINSIZE <# bytes>] [MAXSIZE <# bytes>]
- [LEFTFILL|RIGHTFILL <0..255>]
-
- REPL <str> BY <str> ....................................... 12
- [OR <str> WHEN <name>] [WILD] [WORD] [CONTEXT]
- [TIMES <#>] [EVERY <#>] [AFTER <#>] [CASE]
- [NOCASE] [FIXCASE] [CAP|DECAP] [FIT] [ZERO]
- [MINSIZE <# bytes>] [MAXSIZE <# bytes>]
- [LEFTFILL|RIGHTFILL <0..255>]
-
- STRIP [+|-]<str> TO [+|-]<str> ............................ 13
- [NEST] [WILD] [WORD] [TIMES <#>] [EVERY <#>]
- [AFTER <#>] [CASE] [NOCASE] [FIXCASE] [CAP|DECAP]
-
- B.2. Sub-commands.
-
- AFTER <#> ................................................. 26
- CAP ....................................................... 28
- CASE ...................................................... 17
- CONTEXT ................................................... 18
- DECAP ..................................................... 28
- EVERY <#> ................................................. 26
- FIT ....................................................... 26
- FIXCASE ................................................... 17
- LEFTFILL <0.255> .......................................... 27
- MAXSIZE <# bytes> ......................................... 27
- MINSIZE <# bytes> ......................................... 27
- NEST ...................................................... 13
- NOCASE .................................................... 17
- RIGHTFILL <0.255> ......................................... 27
- TIMES <#> ................................................. 26
- WHEN <name> ............................................... 12
- WILD .................................................. 17, 18
- WORD ...................................................... 19
- ZERO ...................................................... 26
-
- B.3. Script-commands.
-
- EXITPXS ................................................... 24
- GLOBAL .................................................... 23
- MODE <name> ............................................... 23
-
-
-
-
- PARex v3.1x User Manual - Page 30
-
- C. Variables.
-
- NAME ...................................................... 20
- VERSION ................................................... 20
- FILE:<name> ............................................... 20
- FIXTIME:[<formatstr>] ..................................... 21
- TIME:[<formatstr>] ........................................ 22
- SRCNAME ................................................... 22
- SRCPATH ................................................... 22
- DSTNAME ................................................... 22
- DSTPATH ................................................... 22
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PARex v3.1x User Manual - Page 31
-