home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / once.txt < prev    next >
Text File  |  1994-10-29  |  4KB  |  109 lines

  1. The following was posted in answer to a question about starting GCP once a
  2. day, everyday the first time and only the first time your computer boots up.
  3.  
  4. I wrote a little REXX command file that checks the OS2.INI file for today's
  5. date. If it doesn't find today's date, it returns an ERRORLEVEL of 0 and
  6. runs GCP and then writes today's date to the OS2.INI file. If it runs a
  7. second time, it will find today's date, return an ERRORLEVEL of 1 and skips
  8. over the GCP stuff. I have this in the Startup.cmd as follows:
  9.  
  10. startup.cmd:
  11. .....beginning lines...
  12. CALL ONETIME.CMD
  13. IF ERRORLEVEL = 1 GOTO ENDIT
  14. E:
  15. CD\GCP
  16. IF EXIST C:\DNL\CURWEATH.GIF ERASE C:\DNL\CURWEATH.GIF
  17. rem    I don't want a "file already exists" error...
  18. @ECHO MAP 3,1,9 > G:\GCPMSG\WEATHER.SND
  19. rem    build a "Weather.snd" object each day to download a weather map...
  20. COMMPASS /PARAMS=CIS /CMD=N
  21. :ENDIT
  22. EXIT
  23. ...end of the Startup.cmd file....
  24.  
  25. The Rexx code I call ONETIME.CMD:
  26.  
  27. /**** File will set the errorlevel to 1 if run a second time *****/
  28. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  29. call SysLoadFuncs
  30. w = SysIni(, 'Onetime', 'Date')      /* Read date from OS2.INI */
  31. if w = date() then                   /* if 'read' date matches today...*/
  32.      r = 1                           /* set return to 1 */
  33.  else
  34.      r = 0                           /* or else set return to 0 */
  35.  
  36. call SysIni, 'Onetime', 'Date', date()      /* write today's date to */
  37.                                             /* os2.ini file */
  38. Exit r;         /* return the appropriate errorlevel to startup.cmd...*/
  39.  
  40. Remember that a REXX program MUST start with a "comment" as it's first
  41. line (/* ... */) to distinguish it from a plain *.cmd file. See the REXX.INF
  42. file in your \OS2\BOOK subdirectory for more info.
  43.  
  44. The above code puts an entry called "Onetime" in the OS2.INI file with
  45. a DATE as the stored data.
  46.  
  47. I also like to download a current weather map but I can't figure out how to
  48. get GCP to do that automatically each day so I build "WEATHER.SND" file
  49. each day from the startup.cmd.  
  50.  
  51. I also download catalogs of the new files from the past 8 days each Saturday
  52. and from different forums then I visit daily. I wrote another REXX cmd file
  53. to check for Saturday and if it is Saturday, to run GCP with a different
  54. /param= file. I have built a bunch of FORUM.DOW files where "FORUM" equals
  55. the appropriate name of each forum. I store these *.DOW files in a zip file
  56. called GCPDOWN.ZIP and then on Sat. I unzip them to the GCPMSG subdirectory.
  57.  
  58. The GCPSUPPO.DOW file looks like:
  59.  
  60. XA1
  61. DIR LONG DES AGE:8 LIB:ALL
  62.  
  63. You can change the "LIB:" to 1,3,6 etc as appropriate... Some forums use
  64. LIB 0 and some use LIB 1 as the first LIB so the first line should be a
  65. valid library number for that forum.
  66.  
  67. I call this file Saturday.cmd and here is how it works.
  68.  
  69. /**** File will set the errorlevel to 1 if run on Saturday *****/
  70. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' 
  71. call SysLoadFuncs 
  72. if Date('w') = "Saturday" then    /* If its Saturday, then... */
  73.      Do
  74.      r = 1      /* set return code to 1 */
  75.      "%RDRV%:"  /* Change to my Ram Drive where I keep all my small files */
  76.      "CD\bat"   /* Change to the appropriate sub directory */
  77.      "unzip gcpdown -d G:\gcpmsg\"    /* unzip the *.DOW files */
  78.      "E:"
  79.      "cd\GCP"
  80.      COMMPASS "/params=SAT /cmd=N"  /* Start GCP with the "Saturday" param */
  81.                                     /* file */
  82.      end
  83.  else do                            /* Or else return a 0 */
  84.      r = 0
  85.      end
  86. Exit r;       /* return the appropriate errorlevel to startup.cmd...*/
  87.  
  88. The Startup.cmd with this code looks like:
  89.  
  90. startup.cmd
  91. .....beginning lines...
  92. CALL ONETIME.CMD
  93. IF ERRORLEVEL = 1 GOTO ENDIT
  94. E:
  95. CD\GCP
  96. IF EXIST C:\DNL\CURWEATH.GIF ERASE C:\DNL\CURWEATH.GIF
  97. @ECHO MAP 3,1,9 > G:\GCPMSG\WEATHER.SND
  98. CALL SATURDAY.CMD
  99. IF ERRORLEVEL = 1 GOTO ENDIT
  100. rem   If Saturday.cmd returns a 1 then it already called CI$ and we can
  101. rem   skip doing it a second time...
  102. COMMPASS /PARAMS=CIS /CMD=N
  103. :ENDIT
  104. EXIT
  105.  
  106.  
  107. Hope this helps... any questions?    Tom Gallaudet 72206,2464
  108.  
  109.