Suppose you want to update your Phonebook to reflect an area code change from 295 to 345. How could you do it? Lets compound the problem by saying that your phone book has over 500 entries and each entry has the usual four phone fields, namely: Business, Home, Alternate and Fax. Each of these fields could contain a number with the area code 295.
Trying to find and replace 2,000 or more numbers manually would be time consuming to say the least.
In this particular case, were in luck since the replacement value '345 has the same number of characters as the original value '295. We can use a utility program called XLATE.EXE to perform the operation. XLATE is available on the Sept/Oct issue of The HP Palmtop Paper ON DISK. Don't confuse this program with the XLATE utility that comes with the HP Connectivity Pack.
Here's how to use XLATE. Put a copy of XLATE.EXE in the same directory as your Phone Books data file.
Be sure to close your Phone Book and open Filer. Go to the DOS prompt by pressing MENU O D and at the DOS prompt type
XLATE 295 345 MYPHONE.PDB NEWPHONE.PDB ( All of this goes on one line.) Press Enter and in a few seconds the DOS prompt will reappear. Type DIR *.PDB and compare the number of bytes in MYPHONE.PDB and NEWPHONE.PDB. If the number of bytes is the same then nothing surprising has happened. To see if the NEWPHONE.PDB file is valid, start the Phone Book application and use the MENU File, Open command. If the NEWPHONE.PDB file appears, then you're ready to close the Phone Book, use Filer to archive the original Phone Book file and rename the new file as MYPHONE.PDB (or whatever name you prefer.) You'll have to put up with the error message, 'Cannot Open File, the next time you start Phone Book. When this happens, just use the MENU File Open command to open the MYPHONE.PDB file.
CAUTION: XLATE is very indiscriminate in how it replaces things. For example, if a note field contained something like $29500.00, it will be changed to $34500.00. Likewise, a street address may be changed from 295 East Grand to 345 East Grand.
There are other utility programs that will let you do pretty much the
same thing as XLATE does. For example, some hex editors will let you search
and replace globally throughout a binary file. But all of the other utilities I've
looked at are equally indiscriminate in their search and replace operations.
When you want to replace a string, such as Ed with another string like Edward in which the number of characters is different you need to run the database program, e.g. Phone Book. You will have to perform the replacements field by field. This is the only way to maintain the integrity of the data file.
Such a search and replace operation done one field at a time in a large database file would be an exercise in frustration tolerance. However, you can reduce the frustration by installing the FASTDB.TSR program in your AUTOEXEC.BAT program and resetting the Palmtop. FASTDB will let you make a number of changes without pausing to update the whole file after every single change.
You can use a System Macro to automate the 'replace. Well show you one such macro designed for the case where we want to replace 295 with 345 only. For another search and replace operation, you would need to create a different macro.
To start the System Macro application, press [CTRL][More] and select an empty macro record, for example Fn+F7. Press ENTER to open the macro edit screen and put 'S&R in the description field and the following code in the Contents field. {HOME}{DEL}{DEL}{DEL}345{F4}{F4} Then press the F7 (Chain) key and select Fn+F7 as the macro to which to chain. This will create a macro that calls itself thereby creating an infinite loop. The finished macro looks like this:
{HOME}{DEL}{DEL}{DEL}345{F4}{F4}{Fn+F7}
Open the Phone Book, and put the cursor on the topmost entry. Be sure you have all entries displayed. Do not try this operation using a subset of the full database. Press enter to show the details of the first entry. Start the process manually by typing F4 (Find) to open up the search dialog window. Then fill in the search string 295. To avoid searching through the Notes field, press TAB and SPACE to deselect the Include Notes check box. Press the F4(Next) key to continue with the set up.
At this point, the first field that contains 295 should be highlighted. Now invoke the macro by pressing:Fn+F7. The macro will run through the entire Phone file searching in each field for '295 deleting it and entering 345 in its place.
Depending on the size of the data file the process may take some time. When it runs out of data, the macro will continue to call itself causing the Palmtop to beep continuously. Just press the CTRL+ MENU (Break) keys to stop the macro.
At the end of the operation the error message 'Text not found will appear. press OK (F10).
Note: The macro works for this example only in which 295 and 345 represent the telephone area codes which are assumed to appear as the first three characters in a field. If you want to change other parts of a field, you'll need to add {RIGHT} and/or {LEFT} keys to the macro to put the cursor at the exact spot where the deletions should begin. You will also need to adjust the number of {DEL} keys in the macro depending on the number of characters you want to delete.
As with any operation that destroys data, your safest course of action is to back up the original data file and work with a copy of it.
Chris Lott
The REPLACE command in MS-DOS 5.0 performs a special kind of copy. It copies files from a source directory to a target directory overwriting files with the same name in the target directory. Adding an /A switch on the command line causes REPLACE to perform almost the opposite task--it Adds (copies) only those source files that are NOT already present in the target directory. Thus two calls to REPLACE, one with the /A switch and one without, accomplish the same thing as one call to COPY as is seen in the following batch file.
REM REPLCOPY.BAT copies files matching first parameter
REM to directory specified by second parameter, even when
REM a read-only file of the same name exists in the target directory.
REPLACE %1 %2 /R
REPLACE %1 %2 /A
The /R switch allows REPLACE to copy over files in the target directory even if they're read-only! And the replaced files retain their read-only status.
Note that where COPY will accept a directory name as its first parameter indicating that all files in the specified directory should be copied, REPLACE demands a complete file specification. For example, instead of COPY C:\NEW C:\OLD, you'd use REPLCOPY C:\NEW \*.* C:\OLD
HP probably chose to omit the REPLACE.EXE program from its ROM version
of DOS 5.0 since the Backup command in Filer does much of what Replace
does. However, if you want to perform a "backup" by using a batch file
then REPLACE may do exactly what you want. It is also an important utility
program for users of the HP 1000CX Palmtops since there is no equivalent
Filer application in these 'DOS-only computers.
Here are some of the advantages of using this drawing program.
1. You can draw easily using the cursor keys and insert the final picture in a MEMO document.
2. TheDraw is great for schemes and lecture notes, or whatever your imagination desires.
3. Its relatively easy to use.
4. Electronic Bulletin Boards used to be rife with TheDraw art in the days before .GIF and .JPG files. If you know a BBS operator, he or she may be able to dig up some of the better examples of TheDraw artwork. Its amazing what people did with simple, DOS based computers 10 years ago.
5. TheDraw is one of the few programs that actually looks good using the four gray scale screen of the HP Palmtop.
Kent Illeman
Screen 1: The Draw's Space Shuttle.
We tracked down version 4.63 of TheDraw. Reportedly this is the latest version. Its available on the Internet via ftp.teleport.com and on this issue of The HP Palmtop Paper ON DISK. TheDraw is one of many such programs that produce "art" using older CGA monitors as well as black and white monitors. The drawings created with TheDraw can be viewed simply by entering the command "TYPE SHUTTLE.ANS at the DOS prompt. However, this trick requires the use of the ANSI.SYS screen driver to work. Since ANSI.SYS is not available on the HP Palmtops, we recommend the ANSI.COM program. Its a TSR program which may be loaded and removed from memory as needed without the need to reboot the computer.
ftp://ftp.internexus.net/pub/figlet/program/ms-dos/
To run Figlet, you simply issue a command at the DOS prompt:
figlet The HP Palmtop Paper
The output will look like the following, only larger.
Screen 2: A Figlet Phrase.
Figlet comes with about twenty different font files. You can design
your own fonts if you're so inclined.
However, if your fingers find the Fn+0 keys too often so that it gets to be a nuisance then you might look for a way to disable the key altogether. Here then is the source code for a small program that will disable the [PRTSC] key on the Palmtop.
Type the following code into MEMO and save the file as C:\NOPSCR.SCR. Preserve a blank line between the code "int 20" and "rcx" and at least one blank line after the final "q"
n nopscr.com
a 100
pop ds
or by [500], 1
rcx
8
w
q
Use the MENU more Terminate All command to get to the DOS prompt. Type the command
DEBUG
Type the command DEBUG < NOPSCR.SCR and press ENTER. If any error messages appear, check your typing and try assembling the code with the DEBUG command again. The result of a successful "compile' will be an 8 byte file called NOPSCR.COM. When you run this program at the DOS prompt, it will disable the PRTSC key altogether. Now you can press the Fn+0 key and the cursor will continue to blink normally and you won't have to wait for the Palmtop to come back to life.
The good thing about this program is that it is not a TSR. it merely sets BIOS int 5 to 1 which disables the function. The bad thing about the program is that you'll have to reboot the Palmtop if you ever do want the use the Fn+0 [PRTSC] key.
The source code and the assembled version are available on this issue's The HP Palmtop Paper ON DISK and on the www.PalmtopPaper.com website. We've also included another program called PRTSC.COM which does pretty much the same thing. However this is a TSR program. That will disable the PRTSC key the first time it's run and enable it the second time it's run from the DOS command line.