Dec 132017
 
Ashton Tate dBase IV Tech Notes for August 1991.
File TN9108.ZIP from The Programmer’s Corner in
Category Dbase Source Code
Ashton Tate dBase IV Tech Notes for August 1991.
File Name File Size Zip Size Zip Type
TNDB0891.TXT 84979 29136 deflated

Download File TN9108.ZIP Here

Contents of the TNDB0891.TXT file


1 UDF Library


Dealing with SET FIELDS

The SET FIELDS command gets highest priority in all operations that have
the FIELDS option. If you SET FIELDS to a particular field or fields and
then attempt to process a field not included in your SET FIELDS list, you
will get an error message.

You can use the TYPE() function to determine the data type of a field or
variable. If a field is not included in the current fields list, it
returns "U", for undefined as it would with a variable that hadn't been
declared only defined as PUBLIC or PRIVATE.

Since the use of SET FIELDS has a potential error-causing effect, it would
be wise to make the issued command sensitive to any specified fields list.
By cycling through all the fields in a structure with a DO WHILE loop and
using TYPE() to test for fields not in the fields list, you can obtain
critical information about a file structure or fields list that no regular
function in dBASE IV provides. Thankfully, a UDF can practically always
fill the bill.

For instance, you could build a fields list to use in macro substitution to
provide field names as is done in the UDF FNames.

The Clock's Ticking

TimeOut() is a UDF that you can use with a PopUp to limit the amount of
time that a user has to make a choice. You can specify the number of
seconds to wait before timing out and you can customize the UDF to take a
specific action when the time out occurs.

When you DEFINE your POPUP, include TimeOut() in a SKIP FOR clause in the
first BAR. Make sure to specify a parameter to indicate the length of a
time out. The program below is an example of how to implement the UDF.
When you run the program, you have 10 seconds to move the highlight or make
a choice. The same is true after each keystoke until a choice is selected
or the popup is aborted.

DEFINE POPUP Test FROM 5,5 TO 10,20
DEFINE BAR 1 OF Test PROMPT " First " SKIP FOR TimeOut(10)
DEFINE BAR 2 OF Test PROMPT " Second "
DEFINE BAR 3 OF Test PROMPT " Third "
DEFINE BAR 4 OF Test PROMPT " Fourth "
ON SELECTION POPUP Test DEACTIVATE POPUP

Special Effects Indexing

For those of you into visual effects, IndxBar can be used in conjunction
with an index to display the progress of your index graphically. It will
draw a bar from a specified coordinate and make it as long as is specified
by the third argument.

The parameters startRow, startCol are the on-screen coordinates where you
want the bar to start, and barLen is how many bar characters you want to
display. To use it, incorporate the UDF into the FOR expression of an
INDEX command such as:

INDEX ON TAG FOR IndxBar( 5,5,25 )

DBTRAP and TALK should be set OFF. It is not recommended that you use such
an index tag with a production .MDX file because every time a record is
modified through BROWSE or EDIT or any other means, your index tag will
need to be updated and you will get a portion of the bar on the screen.
Use it with a non-production MDX file. Since this is a special effect UDF,
it may not be suited for every occasion.

FUNCTION FNames
* by Martin Leon
* Returns a list of fields.

x = 1
mNameList = ""
DO WHILE "" <> FIELD(x)
IF TYPE(FIELD(x)) <> "U"
IF LEN(mNameList) = 0
mNameList = FIELD(x)
ELSE
mNameList = mNameList + "," + FIELD(x)
ENDIF
ENDIF
x = x + 1
ENDDO
RETURN mNameList



FUNCTION Timeout
* Author: Dan Madoni
PARAMETERS t_time

DO CASE
CASE LASTKEY() <> 32
KEYBOARD CHR(32)
RETURN .F.

CASE LASTKEY() = 27
KEYBOARD CHR(27)
RETURN .F.

OTHERWISE
t_key = INKEY(t_time)
ENDCASE

IF t_key <> 0
KEYBOARD CHR(t_key)
ELSE
* Begin your code.
* The code placed in this area will be executed on Time Out
@ 1,0 SAY "PopUp has Timed Out."
* End your code.
KEYBOARD CHR(27)
ENDIF
RETURN .F.


FUNCTION IndxBar
PARAMETERS startRow, startCol, barLen

mComplete = RECNO() / RECCOUNT()
mBars = INT(mComplete * barLen)
@ startRow, startCol SAY REPLICATE(CHR(219), mBars)
RETURN .T.





2 Etc

View Meister

Did you know that you can actually keep a database of graphic images in
your memo file? In your CONFIG.DB file, add a line

WP =

To add a graphic (such as a .GIF file) to a record,

. APPEND MEMO FROM

When you want to view it, simply enter the memo field as you normally would
by pressing Ctrl-Home.

In effect, you have told dBase IV to use a different Word Processor, but in
this case, it is a graphics viewer. This will allow you to display images
without having to RUN an external program.

A simple database might look like :

PART_NO Character 10 Y
PART_NAME Character 25 N
PART_PICT Memo 10 N

Use caution: If you elect to do this, you MAY NOT enter text into the memo
field. Also, if you change your CONFIG.DB file and remove the "WP = " line,
your graphic image will become corrupt if you enter the memo field.

Setting "WP = " can work with various file types.
However, you will want to select one that uses as little memory (RAM) as
possible. Trying to open a large image may cause the error "Insufficient
Memory" or worse, hang the system.

Novell and the TOTAL Command

The following information came from Novell, and has been tested and
verified by them.

Performing a TOTAL command on a Novell Network (totalling to a network
drive) would not work if you are using version 3.02 of the network shells.
If you've switched to an earlier version of the shells, or if you wrote the
file to a local drive, the TOTAL operation would work.

Determining a Drive Status

So, what happens when your custom-made program runs aground when it goes to
look for files on a floppy and the user has no disk inserted. DOS errors
like "Drive not ready" are not trappable by typical ON ERROR routines.
However, there is a way of checking on a drive status and incorporating the
functionality into your programs.

You can obtain a .BIN routine from the download file ISDISK.ARC, available
on our BBS. Using it with the CALL command, an "X" will be returned if a
drive is not ready. The CALL function can be implemented so that you can
use the drive-check utility in expressions. For example, a simple backup
procedure would COPY an open database to drive A only after a drive check.

IF CALL("ISDISK","A")="A"
COPY TO A:ARCHIVE1
ELSE
? "Insert the backup diskette into Drive A:"
ENDIF

Now you Don't, Now you See It

If the CURSOR is set OFF in a program and an error occurs, selecting
"IGNORE" from the "CANCEL IGNORE SUSPEND" error box will turn the cursor
back ON. However, even with the cursor flashing, issuing SET("CURSOR")
returns OFF. No workaround exists for this problem.

Functions within Debug

In order for DEBUG to control program execution, SCOREBOARD, TALK, and STEP
are set to OFF when you are in a DEBUG session. Nevertheless, the user's
program will still reflect the values set by program control. The setting
of SCOREBOARD, TALK and STEP is only an annoyance in those rare occasions
when you may be tracing (via the Display box) the SET() values of these
particular commands. Otherwise they will always show "OFF".

What is more troublesome is the interaction of DEBUG and functions such as
READKEY() because, in some circumstances, the keys pressed in DEBUG are
reflected in the values returned by READKEY(). For example, place the
following code into a program called Testptr.PRG:

SET TALK OFF
CLEAR

x = 7
@ 4,5 SAY "Enter a value:" GET x
READ

IF READKEY()=12 && was an Escape pressed?
RETURN
ENDIF

Activate the Debugger by entering

DEBUG Testptr

Now run the debugger, pressing the Enter key on each line so you can walk
through the code. When the cursor falls on the READKEY() line press D for
Display and type in x as the variable you would like to checkafterwards,
press Escape. That last Escape key will be remembered by dBASE IV and will
be the return value for READKEY()even though you might have pressed
Return for the READ. The line IF READKEY()=12 will evaluate true and the
program will return to the dot prompt, which is not exactly what you might
expect.

There is no workaround for this issue but being aware of the manner in
which the Debugger handles these situations may save you some time
attempting to figure it out.

External Affairs

A memo cannot be fully deleted if an external editor is setup for memo
editing (WP =) in Config.DB. If all the data in the memo is deleted, then
dBASE IV will treat the memo as unchanged and keep the original memo
intact. To workaround this problem, leave at least 1 character (even a
space) in the memo in order to register that a change has been made to the
memo. Then, to delete this 1 character issue:

REPLACE WITH "" && replace with the null string

Label Dej Vu

If a LABEL FORM is called twice from inside a program, an attempt is made
to look for a .LBL file the second time. This is fine if the .LBL file is
actually there but will result in an error if only compiled object files
(.DBO, .LBO, and so on) are present. This may be common in a turnkey
application setting. The error "File does not exist:


 December 13, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)