home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Product / Product.zip / visilotu.zip / SELDOC.PRG < prev    next >
Text File  |  1995-08-31  |  8KB  |  313 lines

  1. !.HEADER
  2. ! Program Name     - SELDOC.PRG
  3. ! Program Function - Program Task for the Sample Lotus Notes Query application
  4. !                    This program provides a dialog allowing the user to 
  5. !                    add selection criteria to be used when querying the Notes database.
  6. !                    The user types in selection criteria in Lotus Notes SELECT syntax
  7. !  
  8. ! Called by        - LNQMAIN.PRG
  9. ! Calls            - <none>
  10. !.spec winsize MAX MAX
  11. !.spec edit 1
  12. !.spec textcol 0 17
  13. !.HEADER
  14. !
  15. ! DEFINITION
  16. ! Some ASL commands can be placed outside of the normal block
  17. ! structure. This block is provided to allow such commands to
  18. ! be accomodated
  19. !
  20. ! Assign boolean variables
  21. !
  22. DECLARE TASK NUMERIC yes = 1
  23. DECLARE TASK NUMERIC no  = 0
  24. !
  25. DECLARE TASK CHAR[4] ThisTask = A.System.ThisTask
  26. !
  27. ! ON SELECT
  28. ! This block is triggered whenever the user selects a control
  29. ! or menu entry.
  30. !
  31. ON SELECT
  32. DO
  33.   CASE A.System.Object
  34.     !
  35.     WHEN "T.W_seldoc.PUSH1"
  36.     DO
  37.       ! 'Push' button marked '...'
  38.     END
  39.     !
  40.     WHEN "T.W_seldoc.STD_PUSH"
  41.     DO
  42.       CASE A.System.Boxnumber
  43.         WHEN 1                                    ! button marked 'OK'
  44.         DO
  45.           ! Interpret OK on a primary window as required
  46.           DEFINE (?pSelection)[0]                 ! copy back to callers vector
  47.           COPY Expression,(?pSelection)
  48.  
  49.           LET T..W_SelDoc'VISIBLE = No
  50.  
  51.         END
  52.         !
  53.         WHEN 2                                    ! button marked 'Reset'
  54.         DO
  55.           !
  56.           DEFINE Expression[0]                    ! clear current vector
  57.           COPY (?pSelection),Expression           ! and refresh from caller
  58.         END
  59.         !
  60.         WHEN 3                                    ! button marked 'Cancel'
  61.         DO
  62.           LET T..W_SelDoc'VISIBLE = No
  63.         END
  64.         !
  65.         WHEN 4                                    ! button marked 'Help'
  66.         DO
  67.           ! help button
  68.           NOTHING
  69.         END
  70.         !
  71.       END
  72.     END
  73.   END
  74. END
  75. !
  76. ! ON DATA
  77. ! This block responds to controls which can accept data entry.
  78. ! It is executed whenever the cursor leaves the control after
  79. ! data has been changed. This is normally used to provide input
  80. ! validation.
  81. !
  82. ON DATA
  83. DO
  84.   CASE A.System.Object
  85.     !
  86.     WHEN "T.W_seldoc.SLE1"
  87.     DO
  88.       ! React to change to data variable 'Expression[Top]'
  89.     END
  90.     !
  91.   END
  92. END
  93. !
  94. ! ON START
  95. ! This block is executed when the program is initially invoked.
  96. ! It is normally used to initialize variables needed during
  97. ! program execution and to open the main window of the
  98. ! application.
  99. !
  100. ON START(pOwnerWindow,pSelection)
  101. DO
  102.   DECLARE GLOBAL POINTER pSelection
  103.   DECLARE GLOBAL POINTER pOwnerWindow
  104.   !
  105.   ! Open the object store holding the user library
  106.   !
  107.   OPEN OBJECTSTORE MyLib,
  108.    NAME ="UserLib.A95",
  109.    LOCATION = S.Control.Path
  110.   !
  111.   ! Assign all variables referred by the windows
  112.   !
  113.   DEFINE Expression[0]                            ! used by SLE control 'T.W_seldoc.SLE1'
  114.   COPY (?pSelection),Expression
  115.  
  116.   LET Top = 1                                     ! used as index by 'SLE' control 'T.W_seldoc.SLE1'
  117.   !
  118.   OPEN WINDOW W_seldoc, , "I.Windows.seldoc",
  119.    OWNERWINDOW = ?pOwnerWindow
  120.  
  121.   LET T.W_seldoc.PUSH1[0]'ENABLED = No            ! temporarily disable the expression builder button
  122.   !
  123.   ! assign the default push button
  124.   !
  125.   LET T.W_seldoc.STD_PUSH[0]'DEFAULT = 1
  126.   !
  127.   ! assign the help button
  128.   !
  129.   LET T.W_seldoc.STD_PUSH[0]'HELPBUTTON = 4
  130. END
  131. !
  132. ! ON QUIT
  133. ! This block is executed when the user uses Close in the
  134. ! system menu.
  135. ! For a secondary window this would imply, 'shut the window'.
  136. ! For a primary window the implication is, 'close the
  137. ! Application'.
  138. !
  139. ON QUIT
  140. DO
  141.   CASE A.System.Object
  142.  
  143.     WHEN "T..W_seldoc"                            ! primary window
  144.       LET T..W_SelDoc'VISIBLE = No
  145.  
  146.     OTHERWISE
  147.       SHUT ?A.System.Object
  148.  
  149.   END
  150. END
  151. !
  152. ! ON ENTER
  153. ! This block is executed when the user hits the enter key.
  154. ! This is normally coded to be equivalent to selecting
  155. ! the default push button (often the OK button).
  156. !
  157. ON ENTER
  158. DO
  159.   IF A.System.Object = "T..W_seldoc"
  160.   DO
  161.     LET A.System.BoxNumber = T.W_seldoc.Std_Push[0]'DEFAULT
  162.     LET A.System.Object = POINTER(T.W_seldoc.Std_Push[0])
  163.     RUN PROGRAM ThisTask, SELECT
  164.   END
  165. END
  166. !
  167. ! ON OPEN
  168. ! The OPEN event is signalled whenever the user 'double clicks'
  169. ! or opens a LIST control
  170. !
  171. ON OPEN
  172. DO
  173.   CASE A.System.Object
  174.     WHEN "T.W_formbldr.LIST1"
  175.     DO
  176.       !
  177.     END
  178.     !
  179.     WHEN "T.W_formbldr.LIST2"
  180.     DO
  181.       !
  182.     END
  183.     !
  184.   END
  185. END
  186. !
  187. ! ON DESKTOP
  188. ! This block is signaled if the user modifies the window in any
  189. ! way, for example, resizing or using the maximize or minimize
  190. ! icons. Code here will take account of any such actions, for
  191. ! example, by resizing controls to account for a new window
  192. ! size.
  193. !
  194. ON DESKTOP
  195. DO
  196.   CASE A.System.Object
  197.     WHEN "T..W_seldoc"
  198.     DO
  199.       CASE A.System.Operation
  200.         WHEN "MAX"
  201.         DO
  202.           !
  203.         END
  204.         !
  205.         WHEN "NORM"
  206.         DO
  207.           !
  208.         END
  209.         !
  210.         WHEN "SIZE"
  211.         DO
  212.           ! Respond to window sizing ( for example by
  213.           ! repositioning or resizing controls )
  214.         END
  215.         !
  216.       END
  217.     END
  218.   END
  219. END
  220. !
  221. ! ERROR event
  222. ! This block is executed when there is a run-time error.
  223. ! You can trap errors here or allow the error message provided
  224. ! to identify the error and stop the program.
  225. !
  226.  
  227. ON ERROR
  228. DO
  229.   DECLARE CHAR[7] ans
  230.   DECLARE NUMERIC i
  231.   !
  232.   ! Message to identify failing module and line
  233.   !
  234.   LET ans = DIALOG("FTB7004", 0,
  235.    A.System.ErrorModule,
  236.    A.System.ErrorLine)
  237.  
  238.   DO i = 1 : A.System.ErrorNumber[0]'ENTRIES
  239.     IF ans = "CANCEL"
  240.       TERMINATE
  241.       !
  242.       ! Display system message corresponding to error
  243.       !
  244.     LET ans = DIALOG ("FTB" || A.System.Errornumber[i], 0,
  245.      A.System.ErrorInfo[i])
  246.   END
  247.  
  248.   STOP
  249. END
  250. !
  251. ! ON STOP
  252. ! This block is executed when the program is terminated.
  253. ! You should use the block to carry out any housekeeping
  254. ! required before closing
  255. !
  256. ON STOP
  257. DO
  258.   !
  259.   STOP
  260. END
  261. !
  262. ! ON SCROLL
  263. ! This event is activated whenver the user manipulates
  264. ! a scroll bar.
  265. ! Window scroll controls or individual scroll controls
  266. ! will activate this event, but not scroll controls
  267. ! on LIST boxes or MLE controls where scrolling is
  268. ! automatically handled by the control.
  269. !
  270. ON SCROLL
  271. DO
  272.   CASE A.System.Object
  273.     !
  274.     WHEN "T.W_seldoc.SCROLL1"                     ! Scroll control
  275.     DO
  276.       CASE A.System.Scroll
  277.         !
  278.         WHEN "V"                                  ! Select on vertical thumb
  279.         DO
  280.           ! Moved thumb, add code to check A.System.ScrollAmt
  281.         END
  282.         !
  283.         WHEN "U"                                  ! Select on unit up
  284.         DO
  285.           ! Insert code to move one unit up
  286.         END
  287.         !
  288.         WHEN "D"                                  ! Select on unit down
  289.         DO
  290.           ! Insert code to move one unit down
  291.         END
  292.         !
  293.       END
  294.     END                                           ! end WHEN 'T.W_seldoc.SCROLL1'
  295.     !
  296.   END
  297. END
  298. ! Add your code for this Event below.
  299.  
  300. ON QUEUE
  301. DO
  302.   DEFINE Expression[0]
  303.   COPY (?pSelection),Expression
  304.  
  305.   LET T..W_SelDoc'VISIBLE = Yes
  306. END
  307.