home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 216.lha / RexxArpLib_v2.1 / rexx / SetRemind.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-02-15  |  4.1 KB  |  137 lines

  1. /* this sets up a reminder file */
  2.  
  3.     call MenuWindow(REMINDERHOST,REMINDERPORT)
  4.  
  5.     text = "   Date:\\   Time:\\Message:\\\\\\\\\\"
  6.  
  7.     call WindowText(REMINDERHOST,text)
  8.     call AddGadget(REMINDERHOST,90,17,"DATE"," ","%d%1%g",500)
  9.     call AddGadget(REMINDERHOST,90,35,"TIME"," ","%d%1%g",500)
  10.     call AddGadget(REMINDERHOST,90,53,"MES1"," ","%d%1%g",500)
  11.     call AddGadget(REMINDERHOST,90,71,"MES2"," ","%d%1%g",500)
  12.     call AddGadget(REMINDERHOST,90,89,"MES3"," ","%d%1%g",500)
  13.     call AddGadget(REMINDERHOST,90,107,"MES4"," ","%d%1%g",500)
  14.     call AddGadget(REMINDERHOST,90,150,"NAG","\ Nag Me \","%d%1%d")
  15.     call AddGadget(REMINDERHOST,474,150,"ADD","\ Add Reminder \","%d%1%d")
  16.     quitflag = 0
  17.  
  18.     call ActivateGadget(REMINDERHOST,"DATE")
  19.  
  20.    nag = 0
  21.    do forever
  22.       if quitflag = 1 then leave
  23.       t = waitpkt(REMINDERPORT)
  24.      do ff = 1
  25.          p = getpkt(REMINDERPORT)
  26.          if c2d(p) = 0 then leave ff
  27.       
  28.          command = getarg(p)
  29.          
  30.          if command ~= "CLOSEWINDOW" then text = getarg(p,1)
  31.          t = reply(p, 0)
  32.          select
  33.            when command = CLOSEWINDOW then do
  34.               call CloseWindow(REMINDERHOST)
  35.               quitflag = 1
  36.            end
  37.            when command = "ADD" then do
  38.              call WriteFile()
  39.              "runwsh remind "date time nag message 
  40.            end
  41.            when command = "DATE" then call ActivateGadget(REMINDERHOST,"TIME")
  42.            when command = "TIME" then call ActivateGadget(REMINDERHOST,"MES1")
  43.            when command = "MES1" then call ActivateGadget(REMINDERHOST,"MES2")
  44.            when command = "MES2" then call ActivateGadget(REMINDERHOST,"MES3")
  45.            when command = "MES3" then  call ActivateGadget(REMINDERHOST,"MES4")
  46.            when command = "MES4" then  call ActivateGadget(REMINDERHOST,"DATE")
  47.            when command = "NAG" then nag = 1 
  48.            otherwise say command 
  49.          end
  50.  
  51.      end
  52.   end
  53.  
  54. exit
  55.  
  56. /* MenuWindow.rexx - menu making function */
  57.  
  58. MenuWindow:
  59. arg menuhost, menuport
  60.  
  61. runwsh  "'x=createhost("menuhost||","||menuport||")'"
  62. mp = openport(menuport)
  63. do i = 1 to 2
  64.   address command 'c:WaitForPort 'menuhost
  65.   address command 'c:WaitForPort 'menuport
  66.   xx=showlist('p',menuhost)
  67.   yy=showlist('p',menuport)
  68.   if xx & yy then leave i
  69. end
  70.  
  71. idcmp = 'CLOSEWINDOW+GADGETUP'
  72. flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+BACKFILL+ACTIVATE'
  73.  
  74. call OpenWindow(menuhost,10,10,screencols()-40,200,idcmp, flags)
  75.  
  76.  
  77. return 0
  78.  
  79. /* GetVar.rexx */
  80.  
  81. GetVar:
  82.   parse arg menuhost, menuport, gadgetname
  83.            call ReadGadget(menuhost,gadgetname)
  84.            t = waitpkt(menuport)
  85.            p = getpkt(menuport)
  86.            string = getarg(p,1)
  87.            t = reply(p,0)
  88.            string = strip(string)
  89. return string
  90.  
  91. WriteFile:
  92.  
  93.    arg filename, type
  94.  
  95.            date = GetVar(REMINDERHOST,REMINDERPORT,"DATE")
  96.            time = GetVar(REMINDERHOST,REMINDERPORT,"TIME")
  97.            mes1 = GetVar(REMINDERHOST,REMINDERPORT,"MES1")
  98.            mes2 = GetVar(REMINDERHOST,REMINDERPORT,"MES2")
  99.            mes3 = GetVar(REMINDERHOST,REMINDERPORT,"MES3")
  100.            mes4 = GetVar(REMINDERHOST,REMINDERPORT,"MES4")
  101.            
  102.    date = strip(date); time = strip(time);   
  103.  
  104.    checkdate = "hd:reminders/"date||"*"
  105.    'list hd:reminders/'date'* | execio stem file.'
  106.    lastfile = file.0-1
  107.    if lastfile > 0 then do
  108.       parse var file.lastfile date'%'nextfile .
  109.       nextfile = nextfile + 1
  110.    end
  111.    else nextfile = 1
  112.    file = date"%"||nextfile
  113.    file = "hd:reminders/"file
  114.  
  115.    checkfile = open(outfile,file,'W')
  116.  
  117.    if checkfile = 0 then return 10
  118.    call writeln(outfile,"date = '"date"'") 
  119.    call writeln(outfile,"time = '"time"'")
  120.    call writeln(outfile,"nag = "nag)
  121.    call writeln(outfile,'message = "'mes1'"')
  122.    message = mes1
  123.    if mes2 ~= "" then do
  124.      call writeln(outfile,'message = message||"\"||"'mes2'"')
  125.      message = message||"\"||mes2
  126.    end
  127.    if mes3 ~= "" then do 
  128.      call writeln(outfile,'message = message||"\"||"'mes3'"')
  129.      message = message||"\"||mes3
  130.    end
  131.    if mes4 ~= "" then do
  132.      call writeln(outfile,'message = message||"\"||"'mes4'"')
  133.      message = message||"\"||mes4
  134.    end
  135.    call close(outfile)
  136. return
  137.