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

  1. !.HEADER
  2. ! Program Name     - SELFLD.PRG
  3. ! Program Function - Program Task for the Sample Lotus Notes Query application
  4. !                    This program provides a dialog allowing the user to 
  5. !                    select the field names to be retrieved from the Lotus Notes database.
  6. !  
  7. ! Called by        - LNQMAIN.PRG
  8. ! Calls            - <none>
  9. !.spec winsize MAX MAX
  10. !.spec textcol 0 17
  11. !.HEADER
  12. !
  13. ! DEFINITION
  14. ! Some ASL commands can be placed outside of the normal block
  15. ! structure. This block is provided to allow such commands to
  16. ! be accomodated
  17. !
  18. ! Assign boolean variables
  19. !
  20. DECLARE TASK NUMERIC yes = 1
  21. DECLARE TASK NUMERIC no  = 0
  22. !
  23. DECLARE TASK CHAR[4] ThisTask = A.System.ThisTask
  24. !
  25. ! ON SELECT
  26. ! This block is triggered whenever the user selects a control
  27. ! or menu entry.
  28. !
  29. ON SELECT
  30. DO
  31.   CASE A.System.Object
  32.     !
  33.     WHEN "T.W_selfld.PUSH1"
  34.     DO
  35.       CASE A.System.Boxnumber
  36.         WHEN 1
  37.         DO
  38.           ! 'Push' button marked 'Select All'
  39.           DEFINE SelList[0]
  40.  
  41.           DO cc=1:FieldList[0]'ENTRIES            ! update unselected items
  42.             INSERT SelList[0]=cc
  43.           END
  44.  
  45.           CALL T.W_SelFld.LIST1'SETCHECK(SelList[0])
  46.         END
  47.         !
  48.         WHEN 2
  49.         DO
  50.           ! 'Push' button marked 'Deselect All'
  51.           DEFINE SelList[0]
  52.  
  53.           CALL T.W_SelFld.LIST1'SETCHECK(SelList[0])
  54.  
  55.         END
  56.         !
  57.       END
  58.     END
  59.     !
  60.     WHEN "T.W_selfld.STD_PUSH"
  61.     DO
  62.       CASE A.System.Boxnumber
  63.         WHEN 1                                    ! button marked 'OK'
  64.         DO
  65.           DEFINE SelList[0]
  66.           CALL T.W_SelFld.LIST1'QUERYCHECK(SelList)
  67.  
  68.           ! Interpret OK on a primary window as required
  69.           DEFINE (?pSelectFlag)[0]
  70.           COPY SelList,(?pSelectFlag)             ! caller's vectors
  71.  
  72.           LET T..W_SelFld'VISIBLE = No
  73.  
  74.           SIGNAL PROGRAM A.System.Master
  75.  
  76.         END
  77.         !
  78.         WHEN 2                                    ! button marked 'Cancel'
  79.         DO
  80.  
  81.           LET T..W_SelFld'VISIBLE = No
  82.         END
  83.         !
  84.         WHEN 3                                    ! button marked 'Help'
  85.         DO
  86.           ! help button
  87.           NOTHING
  88.         END
  89.         !
  90.       END
  91.     END
  92.     !
  93.     WHEN "T.W_selfld.LIST1"
  94.     DO
  95.       ! list box set for single select mode
  96.  
  97.     END
  98.   END
  99. END
  100. !
  101. ! ON DATA
  102. ! This block responds to controls which can accept data entry.
  103. ! It is executed whenever the cursor leaves the control after
  104. ! data has been changed. This is normally used to provide input
  105. ! validation.
  106. !
  107. ON DATA
  108. DO
  109.   CASE A.System.Object
  110.     !
  111.   END
  112. END
  113. !
  114. ! ON START
  115. ! This block is executed when the program is initially invoked.
  116. ! It is normally used to initialize variables needed during
  117. ! program execution and to open the main window of the
  118. ! application.
  119. !
  120. ON START(pSelectFlag,pColumnName,pOwnerWindow)
  121. DO
  122.   DECLARE GLOBAL POINTER pSelectFlag              ! pointer to vector of columns selected
  123.   DECLARE GLOBAL POINTER pColumnName              ! pointer to vector of column names
  124.   !
  125.   ! Open the object store holding the user library
  126.   !
  127.   OPEN OBJECTSTORE MyLib,
  128.    NAME ="UserLib.A95",
  129.    LOCATION = S.Control.Path
  130.   !
  131.   ! Call procedure to define data for list control(s)
  132.   !
  133.   CALL List_Define
  134.  
  135.   COPY (?pColumnName),FieldList                   ! copy the data from the caller's vector
  136.   COPY (?pSelectFlag),SelList                     ! copy the data from the caller's vector
  137.  
  138.   DEFINE SetCheck[0]
  139.   DO ss=1:SelList[0]'ENTRIES
  140.     IF SelList[ss]
  141.       INSERT SetCheck[0]=ss
  142.   END
  143.  
  144.   !
  145.   OPEN WINDOW W_selfld, , "I.Windows.selfld",
  146.    OWNERWINDOW = (?pOwnerWindow)
  147.  
  148.   MODIFY W_SelFld,                                ! prohibit window from being
  149.    MINX = W_SelFld'SIZEX,                         ! sized smaller than when it
  150.    MINY = W_SelFld'SIZEY                          ! was opened
  151.  
  152.  
  153.   LET MarginRight = W_selfld'SIZEX -              ! store details of Listbox & Window
  154.    T.W_selfld.LIST1'SIZEX -                       ! to be used for resizing
  155.    T.W_selfld.LIST1'X
  156.  
  157.   LET MarginTop = W_selfld'SIZEY -
  158.    T.W_selfld.LIST1'SIZEY -
  159.    T.W_selfld.LIST1'Y
  160.  
  161.  
  162.   CALL T.W_selfld.LIST1'SETCHECK(SetCheck[0])
  163.   !
  164.   ! assign the default push button
  165.   !
  166.   LET T.W_selfld.STD_PUSH[0]'DEFAULT = 1
  167.   !
  168.   ! assign the help button
  169.   !
  170.   LET T.W_selfld.STD_PUSH[0]'HELPBUTTON = 3
  171.  
  172. END
  173. !
  174. ! Construct the arrays needed to support list controls
  175. !
  176. PROCEDURE List_Define
  177. DO
  178.   !
  179.   ! Define data to handle list 'T.W_selfld.LIST1'
  180.   !
  181.   DEFINE FColumns[0]                              ! REFERENCE vector
  182.   DEFINE FLayout[0]                               ! EXPRESSION vector
  183.   !
  184.   ! fill the EXPRESSION vector
  185.   !
  186.   INSERT FLayout[0]="WIDTH=200 SEPARATOR=YES JUST=LEFT READONLY=YES"
  187.   !
  188.   ! Initialise the referred vectors. These are the vectors
  189.   ! which will contain the data to be displayed
  190.   !
  191.   DEFINE FieldList[0]
  192.   DEFINE Selected[0]
  193.   !
  194.   ! fill the REFERENCE vector to point to these vectors
  195.   !
  196.   INSERT FColumns[0] = "FieldList"
  197. END
  198. !
  199. ! ON QUIT
  200. ! This block is executed when the user uses Close in the
  201. ! system menu.
  202. ! For a secondary window this would imply, 'shut the window'.
  203. ! For a primary window the implication is, 'close the
  204. ! Application'.
  205. !
  206. ON QUIT
  207. DO
  208.   CASE A.System.Object
  209.  
  210.     WHEN "T..W_selfld"                            ! primary window
  211.       LET T..W_SelFld'VISIBLE = No
  212.  
  213.     OTHERWISE
  214.       SHUT ?A.System.Object
  215.  
  216.   END
  217. END
  218. !
  219. ! ON ENTER
  220. ! This block is executed when the user hits the enter key.
  221. ! This is normally coded to be equivalent to selecting
  222. ! the default push button (often the OK button).
  223. !
  224. ON ENTER
  225. DO
  226.   IF A.System.Object = "T..W_selfld"
  227.   DO
  228.     LET A.System.BoxNumber = T.W_selfld.Std_Push[0]'DEFAULT
  229.     LET A.System.Object = POINTER(T.W_selfld.Std_Push[0])
  230.     RUN PROGRAM ThisTask, SELECT
  231.   END
  232. END
  233. !
  234. ! ON OPEN
  235. ! The OPEN event is signalled whenever the user 'double clicks'
  236. ! or opens a LIST control
  237. !
  238. ON OPEN
  239. DO
  240.   IF A.System.Object = "T.W_selfld.LIST1"
  241.   DO
  242.     !
  243.   END
  244. END
  245. !
  246. ! ON DESKTOP
  247. ! This block is signaled if the user modifies the window in any
  248. ! way, for example, resizing or using the maximize or minimize
  249. ! icons. Code here will take account of any such actions, for
  250. ! example, by resizing controls to account for a new window
  251. ! size.
  252. !
  253. ON DESKTOP
  254. DO
  255.  
  256.   CASE A.System.Operation
  257.     WHEN "MAX"
  258.     DO
  259.       !
  260.  
  261.       MODIFY T.W_selfld.LIST1,
  262.        SIZEX = T..W_selfld'SIZEX - MarginRight -
  263.        T.W_selfld.LIST1'X,
  264.        SIZEY = T..W_selfld'SIZEY - MarginTop -
  265.        T.W_selfld.LIST1'Y
  266.  
  267.     END
  268.     !
  269.     WHEN "NORM"
  270.     DO
  271.       !
  272.       MODIFY T.W_selfld.LIST1,
  273.        SIZEX = T..W_selfld'SIZEX - MarginRight -
  274.        T.W_selfld.LIST1'X,
  275.        SIZEY = T..W_selfld'SIZEY - MarginTop -
  276.        T.W_selfld.LIST1'Y
  277.     END
  278.     !
  279.     WHEN "SIZE"
  280.     DO
  281.       ! Respond to window sizing ( for example by
  282.       ! repositioning or resizing controls )
  283.       MODIFY T.W_selfld.LIST1,
  284.        SIZEX = T..W_selfld'SIZEX - MarginRight -
  285.        T.W_selfld.LIST1'X,
  286.        SIZEY = T..W_selfld'SIZEY - MarginTop -
  287.        T.W_selfld.LIST1'Y
  288.     END
  289.     !
  290.   END
  291.  
  292.  
  293. END
  294. !
  295. ! ERROR event
  296. ! This block is executed when there is a run-time error.
  297. ! You can trap errors here or allow the error message provided
  298. ! to identify the error and stop the program.
  299. !
  300.  
  301. ON ERROR
  302. DO
  303.   DECLARE CHAR[7] ans
  304.   DECLARE NUMERIC i
  305.   !
  306.   ! Message to identify failing module and line
  307.   !
  308.   LET ans = DIALOG("FTB7004", 0,
  309.    A.System.ErrorModule,
  310.    A.System.ErrorLine)
  311.  
  312.   DO i = 1 : A.System.ErrorNumber[0]'ENTRIES
  313.     IF ans = "CANCEL"
  314.       TERMINATE
  315.       !
  316.       ! Display system message corresponding to error
  317.       !
  318.     LET ans = DIALOG ("FTB" || A.System.Errornumber[i], 0,
  319.      A.System.ErrorInfo[i])
  320.   END
  321.  
  322.   STOP
  323. END
  324. !
  325. ! ON STOP
  326. ! This block is executed when the program is terminated.
  327. ! You should use the block to carry out any housekeeping
  328. ! required before closing
  329. !
  330. ON STOP
  331. DO
  332.   !
  333.   STOP
  334. END
  335. ! Add your code for this Event below.
  336.  
  337. ON QUEUE
  338. DO
  339.   DEFINE FieldList[0]
  340.   DEFINE SelList[0]
  341.  
  342.   COPY (?pColumnName),FieldList
  343.   COPY (?pSelectFlag),SelList
  344.  
  345.   DEFINE SetCheck[0]
  346.   DO ss=1:SelList[0]'ENTRIES
  347.     INSERT SetCheck[0]=SelList[ss]
  348.   END
  349.  
  350.   CALL T.W_selfld.LIST1'SETCHECK(SetCheck[0])
  351.  
  352.   LET T..W_SelFld'VISIBLE = Yes
  353. END
  354.