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

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