[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
##############################################################################
###+----------+###############################################################
#+-| GETENV() |--------------------------------------------------+############
#| +----------+ Returns the current value of the DOS environment |############
#+---------------------------------------------------------------+############
##############################################################################
##############################################################################
#+--| Summary |----------------+##############################################
#| #INCLUDE system.hdr |##############################################
#+-----------------------------+##############################################
##############################################################################
##############################################################################
#+--| Syntax |--------------------------------------+#########################
#| FUNCTION CHAR getenv PROTOTYPE |#########################
#| PARAMETERS CONST CHAR environ_variable |#########################
#+--------------------------------------------------+#########################
##############################################################################
##############################################################################
########+---| Description |------------------------------------------+########
########| The getenv() function returns the current value of the DOS |########
########| environment variable environ_variable. If the variable is |########
########| not found, a NULL string is returned. |########
########+------------------------------------------------------------+########
##############################################################################
##############################################################################
#########+--| Example 1 |-------------------------------------------+#########
#########| * The FORCE compiler searches the environment for |#########
#########| * the "FORCE.HDR" path. This tells the compiler |#########
#########| * where the .hdr files exist. |#########
#########| |#########
#########| search_path = getenv( "FORCE.HDR" ) |#########
#########| IF search_path <> "" |#########
#########| ? ".hdr files exist in directory", search_path |#########
#########| ELSE |#########
#########| ? "The compiler assumes all .hdr files are" |#########
#########| ? "located in directory", curdir() |#########
#########| ENDIF |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 2 |-------------------------------------------+#########
#########| * file: \force\sample\srchpath.prg |#########
#########| * (** source code included with compiler **) |#########
#########| * This function searches the PATH for the 1st |#########
#########| * occurrence of a file and returns the full pathname |#########
#########| * of the file (drive\directory\file). |#########
#########| |#########
#########| FUNCTION CHAR search_path |#########
#########| PARAMETERS CHAR CONST filename |#########
#########| VARDEF |#########
#########| CHAR(128) path && max 128 characters |#########
#########| BYTE p[128] BASED path |#########
#########| CHAR(128) directory |#########
#########| BYTE d[128] BASED directory |#########
#########| CHAR(128) fullname |#########
#########| INT i,k |#########
#########| ENDDEF |#########
#########| path = getenv( "PATH" ) |#########
#########| IF path = "" |#########
#########| path = curdir()+"\"+filename |#########
#########| IF exist( path ) |#########
#########| RETURN path |#########
#########| ELSE |#########
#########| RETURN "" |#########
#########| ENDIF |#########
#########| ENDIF |#########
#########| i = 0 |#########
#########| DO WHILE p[i] <> 0 && go to the end of |#########
#########| && path string |#########
#########| |#########
#########| *--- build up directory string from the path |#########
#########| |#########
#########| k = 0 && index into directory |#########
#########| && string |#########
#########| DO WHILE p[i] <> 0 .AND. p[i] <> ';' |#########
#########| d[k] = p[i] |#########
#########| i = i + 1 |#########
#########| k = k + 1 |#########
#########| ENDDO |#########
#########| fullname = directory+"\"+filename |#########
#########| IF exist( fullname ) |#########
#########| RETURN fullname |#########
#########| ENDIF |#########
#########| |#########
#########| IF p[i] = ';' |#########
#########| i = i + 1 |#########
#########| ENDIF |#########
#########| ENDPRO |#########
#########| * eof srchpath.prg |#########
#########+----------------------------------------------------------+#########
##############################################################################
See Also:
exist()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson