home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware 1 2 the Maxx
/
sw_1.zip
/
sw_1
/
TEXT
/
PDX_ALL.ZIP
/
TI131.ASC
< prev
next >
Wrap
Text File
|
1991-12-04
|
8KB
|
265 lines
PRODUCT : Paradox NUMBER : 131
VERSION : All
OS : DOS
DATE : December 4, 1991 PAGE : 1/4
TITLE : Preventing Users From Accidentally Deleting Records
Paradox allows users to easily delete records from a table. Some
users, though, may prefer to have Paradox verify that a specific
record should be deleted. This can be quickly accomplished with
a small PAL script and an adjustment to the way Paradox handles
the <Delete> key.
While this verification process is easy to add, it can seem
difficult to those with a limited exposure to Paradox. Before
attempting the techniques discussed here, please make sure you
are familiar with the following concepts:
-- DOS directories. Users should be comfortable with the
concept of DOS directories and know how to use the Tools |
More | Directory command to change directories in Paradox.
An introduction to DOS directories is offered in Appendix A
of the Paradox 3.5 Introduction guide while Tools | More |
Directory is covered in Chapter 10 of the Paradox User's
Guide. More information about DOS and directories can be
found in any MS-DOS User's Manual.
-- PAL scripts. Users should know what a PAL script is and
how to write and edit one. See the first few chapters of
the PAL User's Guide for information about creating and
using scripts. It would also be useful to know how PAL
works with variables, though this is not required.
-- Network users should also be familiar with Paradox's use of
private directories and the INIT script. Private
directories are covered in Chapter 2 of the Network
Administrator's Guide and the INIT script is discussed in
Chapter 7 of the PAL User's Guide.
Once the verification process is set up, it is simple to use.
The only person who needs a basic understanding of the above
concepts is the one implementing it.
Installing the process requires two steps. First, you will need
a PAL script that makes certain the record should be deleted by
allowing the user to verify the deletion or cancel the operation.
PRODUCT : Paradox NUMBER : 131
VERSION : All
OS : DOS
DATE : December 4, 1991 PAGE : 2/4
TITLE : Preventing Users From Accidentally Deleting Records
The following script shows one example of how this can be
accomplished.
CMode = Sysmode()
If (not (IsFieldView())) and (CMode = "Edit" or
CMode = "CoEdit" or CMode = "DataEntry") Then
Showmenu
"Cancel" : "Oops, do NOT remove this record.",
"Ok" : "Yes, PERMANENTLY delete this record."
Default "Cancel" to DelRec
If (Retval) and (DelRec = "Ok") Then
Del
Endif
Else
Del
Endif
Release Vars CMode, DelRec
To actually delete a record with this script while Paradox is in
an appropriate mode, the user must press <Delete> and then select
Ok from the menu that appears. If the user presses <Delete>
accidentally, selecting Cancel or pressing <Esc> returns the
user to the table without deleting the current record.
To create this script, use the following process:
-- First, load Paradox and change to the directory where
Paradox is installed with the Tools | More | Directory
command. The default directory for Paradox 3.5 is
C:\PDOX35.
-- Next, select Scripts | Editor | Write. When the "Name:"
prompt appears, type DELREC and press <Enter>.
-- When the Script Editor screen appears, type in the script
exactly as it appears above.
-- After you have typed the script into the Script Editor,
press <F2>. Your DELREC script will be saved.
PRODUCT : Paradox NUMBER : 131
VERSION : All
OS : DOS
DATE : December 4, 1991 PAGE : 3/4
TITLE : Preventing Users From Accidentally Deleting Records
The second part of this process actually "adds" the feature to
Paradox and can take one of two forms. Perhaps the quickest way
to do this is to press <Alt-F10>, select Miniscript, type:
SETKEY -83 PLAY "C:\\PDOX35\\DELREC"
and then press <Enter>. This tells Paradox to play the DELREC
script every time the <Delete> key is pressed.
If your copy of Paradox is located in a different directory, be
sure to change the C:\\PDOX35\\ part of the SETKEY command to
reflect the actual directory where Paradox is installed. (Make
certain you use two "back-slashes" (\\) to separate the various
branches of the directory name.)
The Miniscript approach is a good way to test your new script,
for it immediately changes the behavior of the <Delete> key.
There is a drawback, though. The new definition only stays in
effect until you exit Paradox.
To have this feature "permanently" added to your installed copy
of Paradox, include the above line to your INIT script located in
the directory where Paradox is installed. The INIT script is
analogous to the DOS AUTOEXEC.BAT file; that is, Paradox
automatically looks for (and executes) the INIT script every time
the program starts. Network users will need to have an INIT
script located in their private directories; that is, the
directory where their personalized PARADOX.CFG file is located.
To change an existing INIT script, select Scripts | Editor | Edit
from the main Paradox menu. If you get an error message similar
to "Cannot find INIT script", you may not have an INIT script and
should use Scripts | Editor | Write to create one. Be sure to
change to the proper directory before creating the INIT script.
There are other ways to design the DELREC script. The one given
earlier is not the only way to approach the process, although it
does follow good programming rules. It makes certain the user is
in a mode where records can be deleted, allows the user to press
the <Esc> key during the menu and "cleans up after itself" by
PRODUCT : Paradox NUMBER : 131
VERSION : All
OS : DOS
DATE : December 4, 1991 PAGE : 4/4
TITLE : Preventing Users From Accidentally Deleting Records
clearing the variables it defines. An alternate approach for
DELREC might be:
@ 0,0 "Delete this record? (Y/N): "
Accept "A1" Picture "{Y,N}" Default "N" Required To DelRec
If DelRec = "Y" Then
Del
Endif
This example is not as detailed as the earlier one, but it can be
just as effective. It also does less error checking, potentially
making life more difficult for the average user. Still, with a
little work, it could be as useful as the first example script.
If this second approach is used for DELREC, the user will have to
press the <Delete> key, hit <Backspace> to delete the default "N"
value which appears in the upper left corner of the screen, type
Y and finally press <Enter> before the record will be erased.
As you can see, PAL allows you to approach a specific problem
from different directions. The PAL User's Guide describes the
syntax and use of each command (in Chapter 20) and function
(Chapter 21) used in the two example scripts. It is a good
resource for any questions you might have along these lines.
Feel free to experiment with different variations of these
examples (or to create your own approach). Make certain, though,
to make backups of any data files you experiment with.