home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / os2 / programm / 7959 < prev    next >
Encoding:
Text File  |  1993-01-24  |  2.9 KB  |  63 lines

  1. Path: sparky!uunet!ukma!gatech!swrinde!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!uicvm.uic.edu!u09046
  2. Organization: University of Illinois at Chicago
  3. Date: Sun, 24 Jan 1993 11:45:03 CST
  4. From: Bob Jackiewicz <U09046@uicvm.uic.edu>
  5. Message-ID: <93024.114503U09046@uicvm.uic.edu>
  6. Newsgroups: comp.os.os2.programmer
  7. Subject: Help with DosScanEnv/DosSearchPath
  8. Lines: 53
  9.  
  10. Am I going nuts? The small file enclosed below is the one which is listed
  11. in the online reference (CP Reference). However, when I try to run it,
  12. it says that the environment variable is not found. How can it not find
  13. PATH? I also tried with LIBPATH, DPATH, and others. I'm using CSD 28 (CSet/2)
  14. and GA+SP. Is there some call I need to make before I run this?? I've tried
  15. this with DosScanEnv and DosSearchPath, and with just DosSearchPath with
  16. the proper vector set (I think). I've also tried putting the ENVVARNAME and
  17. FILENAME into regular strings, with no better luck. Any help is appreciated.
  18.  
  19. #define INCL_DOSFILEMGR
  20. #include <os2.h>
  21. #include <stdio.h>
  22.  
  23. #define ENVVARNAME   "PATH"       /* Environment variable name */
  24. #define FILENAME     "test.c"    /* File for which to search */
  25.  
  26. main() {
  27.    PSZ       ResultPointer;         /* Environment scan result
  28.                                         pointer (returned) */
  29.    BYTE      ResultBuffer[128];     /* Path search result
  30.                                         (returned) */
  31.    APIRET    rc;                    /* Return code */
  32.  
  33.   /** Scan environment segment for PATH; notice the far-string **/
  34.   /**   pointer specification ("%Fs") used to print.           **/
  35.  
  36.    if(!(rc=DosScanEnv(ENVVARNAME,  /* Environment variable name */
  37.                       ResultPointer)))  /* Scan result pointer
  38.                                             (returned) */
  39.      printf("%s is %Fs\n", ENVVARNAME, ResultPointer);
  40.  
  41. /* This comes out as 203, environment variable not found */
  42. printf("RC 1 = %d\n", rc);
  43.    /** Search current directory + PATH variable for "test.c"  **/
  44.    if(!(rc=DosSearchPath(SEARCH_CUR_DIRECTORY,    /* Search control
  45.                                                        vector */
  46.                          ENVVARNAME,      /* Search path reference
  47.                                               string */
  48.                          FILENAME,        /* File name string */
  49.                          ResultBuffer,    /* Search result
  50.                                               (returned) */
  51.                        sizeof(ResultBuffer)))) /* Length of search
  52.                                                      result */
  53.      printf("Found desired file -- %s\n", ResultBuffer);
  54.  
  55. /* This comes out as 2, file not found */
  56. printf("RC 2 = %d\n", rc);
  57.  }
  58.  
  59.   Brought to you by the sick mind of      University of Illinois at Chicago
  60.   Bob Jackiewicz, writer of wrongs,                    BITNET: U09046@UICVM
  61.   wronger of rights; not UIC.                InterNet: U09046@uicvm.uic.edu
  62.   "640K ought to be enough for anybody." - Bill Gates, 1981
  63.