Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Foxlib v1.0 - <b>usage example 2</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Usage Example 2

The next example uses the NODRIVES FOXLIB command.  If you wanted to
determine the number of logical drives installed on an IBM PC, you would
perform the following steps from the dot prompt or FoxPro command window:

. load c:\FOXLIB\nodrives
. FOXLIB = "NODRIVES"
. call nodrives with FOXLIB
. ?asc(substr(FOXLIB,1,1))
6
. release module nodrives

there are six drives installed on this computer system (drives A, B, C, D,
E, and F).  Let's examine each dot prompt command in detail.

(1) We loaded the command NODRIVES.bin into memory.  Notice you do not use
the extension (.bin) of the file you are loading.

(2) We created a parameter, NODRIVES, that we will be sending to the
NODRIVES command.  ONLY SEND THE PARAMETER SPECIFIED IN EACH FOXLIB COMMAND,
I.E. DO NOT SEND A PARAMETER OTHER THAN WHAT IS ASKED OF YOU FOR EACH FOXLIB
COMMAND.

(3) We called the NODRIVES command with the parameter "NODRIVES" (You can
pass character parameters to FOXLIB in either lower or upper case).

(4) We determined the number of installed drives by converting the result to
an ASCII code.

(5) Finally, we released the command nodrives.bin from memory.  AFTER YOU
LOAD AND CALL THE COMMAND YOU WANT TO USE, ALWAYS RELEASE IT FROM MEMORY.

When a FOXLIB command returns a value, you may have to convert the value to
an ASCII code using just two FOX functions - SUBSTR and ASC.  The SUBSTR and
ASC functions are included with your FOX product (i.e. FoxBASE + and
FoxPro).

The SUBSTR function returns a specified number of characters from a string.
For example, the string that was passed to the NODRIVES command was
"NODRIVES."  Since the NODRIVES command returns the value (number of
installed drives) in the first letter of the string "NODRIVES" (in this case
the letter N of NODRIVES), all we have to do is obtain the value of the
first letter of the string.

. load nodrives
. FOXLIB = "NODRIVES"
. call nodrives with FOXLIB
. ?substr(FOXLIB,1,1)
. HERE YOU WOULD SEE THE ASCII CODE "SPADE" SYMBOL

We will convert the ASCII code "SPADE" symbol to a number to determine the
number of installed drives.  We'll do this using the ASC function.

. ?asc(substr(FOXLIB,1,1))
6
. release module nodrives

If this seems complicated - DON'T WORRY!  Just follow the instructions for
each command and you'll do just fine.  Please refer to your FOX manual for
questions using the SUBSTR and ASC functions.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson