home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / bazy / fiasco_2.1 / databases / organizer / checkappointments.frx < prev    next >
Text File  |  1997-10-19  |  3KB  |  160 lines

  1. /* checkappointments.frx
  2.  * Copyright © 1997 Nils Bandener
  3.  * $VER: checkappointments.frx 6.4 (19.10.97)
  4.  */
  5.  
  6. scriptname = "Check Appointments"
  7.  
  8. Options Results
  9.  
  10. fiasco_port = address()
  11.  
  12. Signal on Syntax
  13. Signal on Halt
  14. Signal on Break_C
  15. Signal on Failure
  16.  
  17. LockGUI
  18.  
  19. /*
  20.  * Get the number of the
  21.  * current day of the week
  22.  */
  23.  
  24. select
  25.     when date(w) = "Monday" then weekday = 0
  26.     when date(w) = "Tuesday" then weekday = 1
  27.     when date(w) = "Wednesday" then weekday = 2
  28.     when date(w) = "Thursday" then weekday = 3
  29.     when date(w) = "Friday" then weekday = 4
  30.     when date(w) = "Saturday" then weekday = 5
  31.     when date(w) = "Sunday" then weekday = 6
  32.     otherwise weekday = -1
  33. end
  34.  
  35. /*
  36.  * Build a formula that is able to search for
  37.  * the appointments that should be announced.
  38.  */
  39.  
  40. NewSearchInfo 'Formula "announce != -1 && !cancelled && !notshow ? (UseDate ? datediff(currentdate(), date) <= announce && datediff(currentdate(), date) >= 0 : UseDay && announce < 7 ? (day - ' || weekday || ' >= 0 ?  day - ' || weekday || ' <= announce : 7 + day - ' || weekday || ' <= announce) : 0 ) : 0" Var "siname"'
  41.  
  42. /*
  43.  * Search for the appointments and store all
  44.  * matches in a stem variable
  45.  */
  46.  
  47. Find 'SearchInfo "' || siname || '" Stem searchresult'
  48.  
  49. string = ""
  50.  
  51. if searchresult.count = 0 then
  52. do
  53.     RequestChoice '"No appointments found" "Ok" Title "Appointments"'
  54. end
  55. else
  56. do
  57.     /*
  58.      * Build a string that displays the
  59.      * found appointments
  60.      */
  61.  
  62.     string = "Appointments found:"
  63.  
  64.     do i = 1 to searchresult.count
  65.  
  66.         GetField "record" searchresult.i "stem rd"
  67.  
  68.         if rd.important then
  69.         do
  70.             string = string || "*n_______________________________________*n** "
  71.         end
  72.         else
  73.         do
  74.             string = string || "*n  "
  75.         end
  76.  
  77.         if rd.usedate then
  78.         do
  79.             string = string || i || ".: " || rd.date || ", " || rd.time || ": " || rd.short
  80.         end
  81.         else if rd.useday then
  82.         do
  83.             getattr 'field name day labels var daylabels'
  84.  
  85.             d = rd.day
  86.  
  87.             string = string || i || ".: " || daylabels.d || ", " || rd.time || ": " || rd.short
  88.         end
  89.  
  90.         if rd.important then
  91.         do
  92.             string = string || "*n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯"
  93.         end
  94.     end
  95.  
  96.     /*
  97.      * Display the string
  98.      */
  99.  
  100.     RequestNumber 'title "Appointments" Text "' || string || '*n*nShow an appointment (0 = Do not show)?"'
  101.  
  102.     if rc = 0 then
  103.     do
  104.         if result > 0 & result <= searchresult.count then
  105.         do
  106.             ActiveRecord record searchresult.result
  107.         end
  108.     end
  109. end
  110.  
  111.  
  112.  
  113. bail_out:
  114.  
  115. Interpret Address fiasco_port
  116.  
  117. UnlockGUI
  118. ResetStatus
  119.  
  120. exit
  121.  
  122. syntax:
  123. failure:
  124.  
  125. if show("Ports", fiasco_port) then
  126. do
  127.     Address Value fiasco_port
  128.  
  129.     RequestChoice '"Error ' || rc || ' in line ' || sigl || ':*n' || errortext(rc) || '" "Cancel" Title "' || scriptname || '"'
  130. end
  131. else
  132. do
  133.     say "Error" rc "in line" sigl ":" errortext(rc)
  134.     say "Enter to continue"
  135.     pull dummy
  136. end
  137.  
  138. call bail_out
  139.  
  140. halt:
  141. break_c:
  142.  
  143. if show("Ports", fiasco_port) then
  144. do
  145.     Address Value fiasco_port
  146.  
  147.     RequestChoice '"Script Abort Requested" "Abort Script" Title "' || scriptname || '"'
  148. end
  149. else
  150. do
  151.     say "*** Break"
  152.     say "Enter to continue"
  153.     pull dummy
  154. end
  155.  
  156. call bail_out
  157.  
  158.  
  159.  
  160.