Excerpts from an article by Miriam Liskin in Computer Currents April, 1986:
" You can use the comment marker '&&' instead of '*', which allows you to
include a comment on the same line as a program statement; all characters
to the right of the two ampersands are ignored. If you use the FOUND()
function rather than the older EOF(), that tests more directly for the
outcome of a FIND or a SEEK, and thus allows you to use eminently
readable IF FOUND() and IF .NOT. FOUND() constructions instead of the
less intuitive IF .NOT. EOF() and IF EOF().
The SET ORDER command allows you to designate by number any of the
indexes opened with a database as the "master" index. This index,
normally the first one named in the USE or SET INDEX command, controls
the order in which records are processed, and is the only index that may
be use to FIND or SEEK records. To select the second index named in the
USE command, you could use:
SET ORDER TO 2
You can also view the file in sequential order (as if no indexes were
open) with:
SET ORDER TO 0
The REPLICATE() function is used to repeat a character string a
specified number of times. For example, you could use this command to
draw a line 50 characters long consisting of alternating dashes and
asterisks, starting at row 10, column 15:
@ 10,15 SAY REPLICATE("-*",25)
You are not limited to the standard "printable" characters, since any
character may be specified by its ASCII code using the CHR() function:
@ 10,15 SAY REPLICATE (CHR(223),50)
You can easily draw continuous single- or double-lined boxes with a
new variant of the @ ... SAY command. The box is defined by its upper
left and lower right corners, and is composed of single-line graphics
characters unless you include the DOUBLE keyword. As an example, you
could draw a double-lined box around the entire screen (leaving line 0
for messages) with:
@ 1,0 to 24,79 DOUBLE
If the two row coordinates are the same, the "box" reduces to a
horizontal line; similarly, vertical lines are created by using the same
column coordinate. You can use the CLEAR command to quickly blank out a
rectangular area on the screen:
10,10 to 15,59 CLEAR
The PICTURE command offers several useful options. The -Y- template
symbol, which may be used with either logical or character fields,
permits only the characters "Y", "N", "y" or "n" to be entered, and
automatically converts the user's entry to upper case. This allows you
to ask a yes-or-no question, with built-in validation of the answer:
STORE .F. TO MANSWER
# 24,10 SAY "Are you sure?";
GET MANSWER PICTURE "Y"
READ
Another PICTURE function -@S-, which allows you to scroll a long
character field through a smaller input "window" on the screen. For
example , to edit a 200-character field in a 50-character space, you
could use:
@ 10,10 SAY "Comments";
GET COMMENTS PICTURE "@S50"
One group of functions allows you to write programs that are less
dependent on a specific hardware and operating system configuration. The
VERSION() function yields the name of the version of FoxPro, while OS()
returns the name and version of the operating system. You could use the
OS() function to check which version of DOS is active before issuing
operating system-specific commands, such as RUN commands that execute
external utility programs.
The FKMAX() function returns the number of programmable function keys
present on the keyboard, and the FKLABEL() function yields the names of
these keys. Since FKLABEL() allows you to access the keys by number,
your program does not have to know the correct function key names. Note
that with any keyboard that does not have a separate function key named
"HELP", function key number 1 is reserved for this purpose. On these
systems, which include the IBM PC and many clones, FKMAX() will be one
less than the total number of function keys, and FKLABEL(1) will be the
function key number 2. To illustrate the use of these functions, this
partial program checks whether extra function keys are available, and,
if so, assigns 3 of them special meanings:
IF FMAX() >= 12
SET FUNCTION FKLABEL(10) TO "USE MAILLIST;"
SET FUNCTION FKLABEL(11) TO "SKIP; DISPLAY;"
SET FUNCTION FKLABEL(12) TO "SKIP -1; DISPLAY;"
ENDIF
You can use the GETENV() function to examine the status of the options
that may be set with the operating system SET commands, such as the
search path for programs and batch files found in the current directory,
and the location of COMMAND.COM as specified with SET COMSPEC.
Finally, you can check available disk space with the DISKSPACE()
function. Since this function operates only on the currently logged-in
drive, you must first use SET DEFAULT to switch the default disk if,
for example, you are working on a hard disk and want to check the status
of a floppy before backing up a file. You might also use DISKSPACE()
before beginning a SORT or COPY command to make sure that there is
enough space to complete the command successfully.
Another set of functions allows you to write programs, or more
commonly, procedures, that are less dependent on the names of the
databases, indexes, and fields they operate on. DBF() yields the name of
the currently active database, NDX() returns the name of the nth
index opened with a USE or SET INDEX command. You also have easy access
to the status information in the database file header through the
RECSIZE() function, which returns the record size, LUPDATE(), which
accesses the date of the last update, and RECCOUNT(), which yields the
number of records in the database.
These functions can be combined to construct routines like a general-
purpose file backup procedure. The program could open a series of files,
check the date of last update to decide whether each file must be backed
up, and multiply RECCOUNT() by RECSIZE() to obtain the size of the file.
"
--- TMail v1.31.5
---------------
* Origin: Diablo Valley PCUG-BBS, Walnut Creek, CA 510/943-6238 (1:161/55)
|