A General Description of FPATH and Its Functions

ID: Q115416

The information in this article applies to:

SUMMARY

This a general guideline of the functions contained within the FPATH library. FPATH is a library of string-handling routines for manipulating MS- DOS strings, filenames, and pathnames.

This information was taken from the FPATH.C file, which is distributed with the FoxPro Library Construction Kit.

FPATH itself should be compiled with the large memory model.

MORE INFORMATION

The following information of the individual functions is laid out in the following manner:

   <function name>  // <Brief description>
   ---------------------------------------
   <General description of functionality>

   Usage: <Syntax>
   Returns: <Return value of function>

JUSTFNAME // just file name (stem+ext)

This function returns the filename portion of a file/path name.

Usage:   justfname(pathname)
Returns: string

JUSTSTEM // just stem name

This function returns the stem portion of a file/path name.

Usage:   juststem(pathname)
Returns: string

JUSTEXT // just file extension

This function returns the extension of a file/path name.

Usage:   justext(pathname)
Returns: string

JUSTPATH // just path name (no file name)

This function returns the path portion of a file/path name.

Usage:   justpath(pathname)
Returns: string

JUSTDRIVE // just drive designation

This function returns the drive designation of a file/path name.

Usage:   justdrive(pathname)
Returns: string

FORCEEXT // force file extension to ...

This function returns parameter 1 with the extension changed to parameter 2. If there isn't an extension on parameter 1 already, it adds one.

Usage:   forcetext(pathname,extension)
Returns: string

DEFAULTEXT   // give file a default extension
This function adds parameter 2 as the extension of parameter 1, but only if parameter 1 does not have an extension. If it does, this function simply returns parameter 1.

Usage:   defaultext(pathname,extension)
Returns: string

ADDBS   // add a backslash if one is needed
Add a trailing backslash to a path name, unless there is already one there or the string is empty. Returns a pathname.

Usage:   addbs(pathname)
Returns: string

VALIDPATH // is this a valid path/file name?

Returns TRUE if the filename passed as a parameter is a valid MS-DOS file name.

Usage:   validpath(pathname)
Returns: boolean

CLEANPATH // clean up a file/path name

Returns a cleaned-up file and path name, stripping out invalid chars, eliminating duplicate backslash chars, making sure there aren't too many colons, etc.

Usage:   cleanpath(pathname)
Returns: string

REDUCE // reduce white space to single blank

Reduce multiple white space characters to a single space and trims all leading and trailing white space. If the optional second parameter is non-zero, quoted strings will be unaffected.

Usage:   reduce(string,[skipquotes])
Returns: string

STRFILTER // filter out anything that isn't in second string

Filter out any characters that aren't in filt_str.

Usage:   strfilter(string,filt_str)
Returns: string

WORDS   // number of words in string
Counts the number of words in a string. Words are delimited by characters in the break string, or by DFTBREAK characters if no break string is specified.

Usage:   words(string,[break])
Returns: int

WORDNUM // word number i from string

Returns the "index-th" word in a string, delimited by the break string. If no break string is specified, the function uses spaces, tabs and commas to delimit words.

Usage:   wordnum(string,index,[break])
Returns: string

NEXTWORD // next word from string

Returns the next word in a string, beginning with the index specified by the second parameter. It skips break characters from the index position forward. It accepts an optional third parameter containing a string of break characters. If no break string is specified, only white space characters are break characters.

Usage:   nextword(string,index,[break])
Returns: string

FCTNPARM // function parameter i

Returns the specified parameter in a string of function parameters, accounting for nested parentheses, etc.

Usage:   fctnparm(string,index)
Returns: string Auns: string

BXOR    // xor two numbers
This routine returns the bitwise "exclusive or" of byte1 and byte2.

Usage:   bxor(byte1,byte2)
Returns: int

BOR // or two numbers

This routine returns the bitwise "inclusive or" of byte1 and byte2.

Usage:   bor(byte1,byte2)
Returns: int

BAND // and two numbers

This routine returns the bitwise "and" of byte1 and byte2.

Usage:   band(byte1,byte2)
Returns: int

BNOT // not a number

This routine returns the ones' compliment of byte1.

Usage:   bnot(byte1)
Returns: int

BSHR // shift a number right

This routine returns byte1 shifted right by num positions, or by one position if num is not specified. As bytes are shifted, the new bytes on the left are zero-filled.

Usage:   bshr(byte1,num)
Returns: int

BSHL // shift a number left

This routine returns byte1 shifted left by num positions, or by one position if num is not specified. As bytes are shifted, the new bytes on the right are filled with 0.

Usage:   bshl(byte1,num)
Returns: int

DBL2NUM   // convert 8-byte double to Fox num
This routine returns a FoxPro numeric variable corresponding to the double (8-byte) number passed to it as a character string. It is useful for converting data written by other applications into FoxPro format.

Usage:   dbl2num(8 bytes)
Returns: floating point number

NUM2DBL   // convert Fox num to 8-byte double
This routine returns a double (8 byte) number corresponding to the FoxPro numeric variable passed to it. It is useful for converting data written by other applications into FoxPro format. The double number is returned in a character string.

Usage:   dbl2num(8 bytes)
Returns: String, via value structure

FLOAT2NUM   // convert 6-byte float to Fox num
This routine returns a FoxPro numeric variable corresponding to the real (6-byte) number passed to it as a character string. It is useful for converting data written by other applications into FoxPro format.

Usage:   float2num(6 bytes)
Returns: floating point number

LONG2NUM    // convert 4-byte float to Fox num
This routine returns a FoxPro numeric variable corresponding to the long int (4-byte) number passed to it as a character string. It is useful for converting data written by other applications into FoxPro format.

Usage:   long2num (4 bytes)
Returns: floating point number

INT2NUM   // convert 2-byte float to Fox num
This routine returns a FoxPro numeric variable corresponding to the
int (2-byte) number passed to it as a character string. It is useful
for converting data written by other applications into FoxPro format.

Usage:   int2num (2 bytes)
Returns: floating point number

FPATHTEST   // testing function
Tests for internal fpath functions This is information was taken from the FPATH.C file which is distributed with the FoxPro Library Construction Kit.

This is a library of string handling routines for manipulating MS-DOS strings, filenames and pathnames. It should be compiled with the Large memory model.

Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60 lck KBCategory: kbinterop kbtool kbprg kbref KBSubcategory: FxtoolLck

Last Reviewed: June 27, 1995