home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 121
/
af121sub.adf
/
Change.lzx
/
Change
/
Change.doc
< prev
next >
Wrap
Text File
|
1979-05-29
|
9KB
|
218 lines
This program gives you the ability to search for different strings in files
and to replace them with other string. The file could be binary or ascii.
An example is if you change your harddisk and then most of the old path
names also change. Normally you have to do this file for file by hand. With
change it's much more easier! Only use change in a script with all (or all
needed) files and the replacement is done.
Change is programmed with MaxonC++ and later SAS-C (but mostly in C and
not C++) and it's Public Domain. I give all rights of the program to the
user, but the same way I give no guarantee that the program works well.
Use it of your own risk!
Since version 2.0 Change has a GUI. The elements of the GUI are the same
like the Shell arguments! You can start Change with GUI from WB or from
Shell without arguments. If you give arguments in the shell, Change will
work with this arguments without opening a window!
The program requires OS2.0 (V37) or any later version.
The history of the program is in the source code -> source/Change/Change.c
If you call Change with ?(»Change ?«) you get the following argument list:
FROM/A,SSTRING/A,TO,RSTRING,FOUND/S,HEX/S,LENGTH/S,NOCHANGE/S,NOSIZE/S,
OVERWRITE/S,PATH/S,POS=POSITION/K:
Enter again a ? and you will get a better explanation.
With »Version Change FULL« you get the actual version of this program.
Thats useful for updating.
Explanation of arguments:
FROM the already existing file Change should work with
Starting with 2.33 Change allows use of patterns in file
names. See below for comments.
> needed every time !
SSTRING is the string Change should search for
> needed every time !
TO the file Change should write to
if it's the same like FROM (or their is no TO) it will be
overwritten! (only if there is enough memory to load it,
else the name will get _ at the end)
> needed every time (not with option NOCHANGE)
RSTRING is the replacement for SSTRING
> not needed, if not given an empty string is used
FOUND gives you every tim SSTRING is found or changed a output
(for example: String found at 32C). The number is the hexa-
decimal code of the position.
> not needed, of no use with NOCHANGE
HEX gives you the posibility to enter the strings as hex
numbers. (Some chars can't be entered with the keyboard -
RETURN - 0A for example)
> not needed
LENGTH changes the length information of a BCPL string (first
character contains length of string)
> not needed, of no use with NOCHANGE and same length of
of the strings, idiotic with a normal C-string (with 0 at
end)
NOCHANGE turn of the replacement, only search SSTRING like Search
command in C:, Option FOUND automatical turned on
> not needed, Options TO, LENGTH, OVERWRITE, PATH, RSTRING
not useable
NOSIZE scan case insensitiv
> not needed
OVERWRITE If RSTRING is longer than SSTRING the chars after RSSTRING
will be replaced, if RSTRING is shorter, the rest will be
filled with 0. This option is useful if you change strings
in executable filles, because the length can't be changed
May produce too long files, when RSTRING is larger than
SSTRING and replacement is near the fileend.
> not needed, of no use with same length of the strings
> turned off, when PATH is active
PATH Option to replace path names. It's like overwrite, but the
filling or overwriting starts first, when a 0 is found after
the replacement!
May produce too long files, when RSTRING is larger than
SSTRING and replacement is near the fileend.
> turns off OVERWRITE, useless with same length of strings
ALL deep scanning in directories
> not needed
POS see POSITION
POSITION After POSITION you have to give a hex number of the position
you want to change sstring. If there is no sstring at this
position no replacement would be done. A position you can
get before that with the option NOCHANGE
> not needed, of no use with NOCHANGE
If you give no keywords, the first string is FROM, the second SSTRING, the
third TO and the fourth RSTRING.
File-Patterns: Change supports the usage of file patterns. When multiple
input files are found, the destination must be a directory. So there can
be different cases:
1) Only one source and destination file
- Change works from source to destination
2) One source file and destination directory
- Change stores the destination file with source name in destination
directory.
3) Multiple source and destination directory
- Change stores the files (with ALL paramter also files from sub
directories) in destination with their source name.
4) Multiple source files and one destination name
- Change processes first file and brings an error for next one.
5) No destination given
- Change replaces the file(s).
With parameters NOCHANGE and POSITION, Change may find more positions than
can be replaced by a normal pass. This is because these options display
overlapping areas as well. In Change pass this is not possible.
Change also works with a pattern. If there is a \? in the text (or a ? in
HEX mode) at this position every char will be accepted!
Important:
\? is the pattern
\\ means one \
\ and after this a hex number with 2 digits means the char given
through the ascii-code(f.i. \57 is a W)
(see the examples)
If you enter strings with HEX option all chars of no use are ignored. Only
(0..9 a..f A..F ?) will be recognized. This means you can enter slashes
between the chars to make it better visible.
123a4b52349f009a is the same as 123a_4b52_349f_009a or 123a.4b52.349f.009a
or 1-2-3-a-4-b-5-2-3-4-9-f-0-0-9-a.
At the program start Change tells you the two strings it works with.
Chars from 20 to 7E and from A1 to FF will be shown like given.
. means a non printable char and
_ means a pattern.
At the end the program gives you a status report of the done work:
String ... times found and ... times changed
Examples:
You want to search in the file SYS:Texts/S the name Intel:
--> Change SYS:Texts/S Intel NOCHANGE
With hex option it looks like this:
--> Change SYS:Texts/S 496E74_656C NOCHANGE HEX
If you want to change Intel to Motorola you must give me a destination
(SYS:Texts/S2) and remove NOCHANGE:
--> Change SYS:Texts/S Intel SYS:Texts/S2 Motorola
With NOSIZE you can also scan for intel, InTeL, INTEL and other forms,
FOUND shows you the position of the string:
--> Change SYS:Texts/S Intel SYS:Texts/S2 Motorola NOSIZE FOUND
Use the CD command before that, so the arguments will be shorter
Befehl:
--> CD SYS:Texts
Change S Intel S2 Motorola NOSIZE FOUND
If you want to replace wrong written word MoToRoLa or motorola with the
capitalized version Motorola, use this (remember NOSIZE doesn't change the
destination string):
--> Change S motorola S2 Motorola NOSIZE
If Intel should be replaced only at one position so use POSITION:
--> Change S Intel S2 Motorola POSITION D3 NOSIZE
Alternativly use POS:
--> Change S Intel S2 Motorola POS D3 NOSIZE
If the strings contain spaces use "":
--> Change S "Intel is good" S2 "Motorola is better"
You can also delete the SSTRING in the file:
--> Change S Intel S2 "" or
--> Change S Intel S2
If you want to replace words, which don't differ very much (Disk and Disc
with floppy disc) so use a Pattern:
--> Change S Dis\? S2 "floppy disc"
or
--> Change S 446973? S2 666C6F707079_64697363 HEX
If you want to search for a \ so enter they every time twice. (6 instead
of 3 ...)
--> Change S \\ S2 / --> changes \ to /
--> Change S \\\\ S2 // --> changes \\ to //
--> Change S \\? S2 /? --> changes \? to /? (no pattern !)
but rememeber:
--> Change S \? S2 /? --> changes every char to /?
If SSTRING is "" an error appears.
Plans for the future:
The pattern * for a variable number of chars or the standard Amiga patterns,
like #, ~, ().
Localisation and together with this german texts (The OS errors are already
localized by the OS!).
This program is in the public domain. Use it as you want, but WITHOUT ANY
WARRANTY!
Comments, wishes, money (it is Public Domain, but why not), greetings and
bug reports to
************************************************************************
* snail-mail: * e-mail: *
* Dirk Stoecker * stoecker@amigaworld.com *
* Geschwister-Scholl-Str. 10 * stoecker@rcs.urz.tu-dresden.de *
* 01877 Bischofswerda * world wide web: *
* GERMANY * http://home.pages.de/~Gremlin/ *
* phone: * pgp key: *
* GERMANY +49 (0)3594/706666 * get with finger or from WWW pages *
************************************************************************