home *** CD-ROM | disk | FTP | other *** search
/ TestDrive Windows 1993 Fall / TestDrive Windows 1993 Fall.iso / dbase / form.gen < prev    next >
Encoding:
Text File  |  1993-03-09  |  29.0 KB  |  766 lines

  1.  
  2. Format (.fmt) File Template with POPUP field validation
  3. -------------------------------------------------------
  4. Copyright (c) 1987, 1990, 1991, 1992 Borland International, Inc.
  5.  
  6.  
  7. This template will support POPUPs for VALID clause field validations and
  8. context sensitive help for each field.
  9.  
  10. Example: In "ACCEPT value when" under "Edit options" enter,
  11.         "POPUP" = "vendor->vendor_id ORDER vendor_id REQ SHADOW"
  12.         --------------------------------------------------------
  13.         this will activate a popup if the data entered is invalid for
  14.         that field and will also make the field REQUIRED.
  15.  
  16. Explanation of the POPUP string follows:
  17.  
  18. POPUP              Indicates that a popup will be used for this field.
  19. vendor->vendor_id  Indicates the .DBF to open and FIELD to use as validation.
  20. ORDER vendor_id    Indicates which INDEX TAG to SEEK in.
  21. REQ                Indicates the FIELD requires data (can't be empty).
  22.                    Leave REQ out if the field is NOT required.      OPTIONAL!
  23. SHADOW             Use shadowing effect on popups                   OPTIONAL!
  24. NOTE: The POPUP string must be entered with the quotes as in the example.
  25.  
  26. --------------------------------------------------------------------------------
  27.  
  28. Explanation of the Context Sensitive Help file follows:
  29.  
  30. If you want to create your own help file, here is the structure that is required.
  31.  
  32. Structure for Help Database (.dbf):
  33. <first 6 chars. of the format file name>_H.dbf
  34.  
  35. Field   Field Name  Type        Width  Dec   Tag
  36. -------------------------------------------------
  37.     1   FLD_NAME    Character     10         Yes  Field name to lookup on F1
  38.     2   FLD_HEADNG  Character     25          No  Heading to show user on window
  39.     3   FLD_HELP    Memo          10          No  Help text to show user
  40. -------------------------------------------------
  41.         Total                     46
  42. ε¡¢(x▐»╛∩.¼:88 ;<.▐:86 (=8m8n ;.°:8m8n ;.,:6'8; 8< 8? >;<.g:>5e80 8n.=<<.Ü:8< 8= 8< 8> ;<.╢:/».┤;<.#    :    dbtmp8g /▌    dbtmp8g .τ    tmp8g 8T /    86 8<     \1        \>;<.[    :8; 8T 86 2V        0.Y    ;<.Å    :8w 8v 8< 8x;<        dtl_debug8g /╧    8y    Pick the debug level you want8z8â     1
  43.     ,8é 8\ 0
  44.     ;╡ 1V
  45.     :Can't use FORM.GEN on non-form objects.  Press any key ...8N.å     
  46. 80     %$    "(8< 88 8>  (8< 88 8> 
  47.     U_
  48.  9ús'8k 0+ .. 9Ö? /å 9Φ49É 9W9⌠929ñ40s /x 9óG    .fmo8{;.S:
  49. *-- Format file initialization code --------------------------------------------
  50.  
  51. *-- Some of these PRIVATE variables are created based on CodeGen and may not 
  52. *-- be used by your particular .fmt file
  53. PRIVATE ll_talk, ll_cursor, lc_display, lc_status, ll_carry, lc_proc
  54.  
  55. IF SET("TALK") = "ON"
  56.   SET TALK OFF
  57.   ll_talk = .T.
  58. ELSE
  59.   ll_talk = .F.
  60. ENDIF
  61. ll_cursor = SET("CURSOR") = "ON"
  62. SET CURSOR ON
  63. lc_display = SET("DISPLAY")
  64. 9mrlc_status = SET("STATUS")
  65. *-- SET STATUS was /╤ON when you went into the Forms Designer.
  66. IF lc_status = "OFF"
  67.    SET STATUS ON
  68. .$OFF when you went into the Forms Designer.
  69. IF lc_status = "ON"
  70.    SET STATUS OFF
  71. ENDIF
  72. j8F 8I 0≈X/\,@80     M2∩¬/∩6∩,    wndow    ,9╤A
  73. *-- Window for memo field =9k ?.
  74. DEFINE WINDOW 9= ?,.98B/┤
  75. ll_carry = SET("CARRY") = "ON"
  76. SET CARRY ON
  77. *-- Fields to carry forward during APPEND.
  78. SET CARRY TO)8S ?&& Clear previous SET CARRY TO list
  79. SET CARRY TO 9ä> ?
  80.  
  81. 9A /
  82. ON KEY LABEL F2 ?? chr(7)
  83.  
  84. 9█hDO S_ ?)8S ?&& Open up Lookup Files
  85.  
  86. 9qA /Q0(9█hON KEY LABEL F1 DO Help WITH VARREAD()
  87. <<.≡:
  88. *-- @ SAY GETS Processing. -----------------------------------------------------
  89.  
  90. *--  Format Page: ?
  91. Φ8F 8I 0ε½W9┐9 &9╤A /:READ
  92.  
  93. *-- Format Page: ?
  94.  
  95. =1Zj2?2á*-- Calculated field: =9k ? - L?
  96. ?2╪*-- Memory variable: =9k ?
  97. @ ß9₧ ?,]9₧ ? >2 @ 9ä= ?.├SAY _8-  6¡_86 2vCHR(_8- ?) .⌐REPLICATE(CHR(_8- ?), _86 ?) .≈_8<     "2╪    [    ]>_?     ">9┐< ?.▀áí9b< ?9┐< ?.▀W0┌SAY ?2yM8F 8I 0rM?,.S .▓?2ô    .£    m->>=9k ? 9ß8 /╓PICTURE "9┌" .¿GET ?2     $0<$>.    m->>=9k ? @80     M2ç¬/ç6[,>¬2rOPEN WINDOW wndow? 9ß8 /⌐PICTURE 92 O0┐P/;
  98.    RANGE W!/≡REQUIRED O?P/,P? S/Ω;
  99.     POPUPS87 8= 8.     227    7Picklist coordinates exceed column 79 - move field left9&9 /7   VALID W!0╔S9÷D /╘REQUIRED =9╨D ?( =9k ? )     .AND.S8= 8. 43S8< ? .ì    POPUPS87 8= 8.     21ì   VALID W!/éREQUIRED S? T/Ω;
  100.    ERROR     IIFT8= 8. 0┬"T?    IIFT8= 8. 0τ" R/;
  101.    WHEN R? Q/A;
  102.    DEFAULT Q? c/¿;
  103.    MESSAGE     IIFc8= 8. 0Ç"c?    IIFc8= 8. 0Ñ" 9┐< ?.▀.µ.▀7=+>j".╗
  104. ,,.Θ<<..:*-- Format file exit code -----------------------------------------------------
  105.  
  106. *-- SET STATUS was /ON when you went into the Forms Designer.
  107. IF lc_status = "OFF"  && Entered form with status off
  108.    SET STATUS OFF     && Turn STATUS "OFF" on the way out
  109. .¥OFF when you went into the Forms Designer.
  110. IF lc_status = "ON"  && Entered form with status on
  111.    SET STATUS ON     && Turn STATUS "ON" on the way out
  112. ENDIF
  113. /╓IF .NOT. ll_carry
  114.   SET CARRY OFF
  115. ENDIF
  116. IF .NOT. ll_cursor
  117.   SET CURSOR OFF
  118. ENDIF
  119.  
  120. IF SET( "DISPLAY" ) <> lc_display
  121.   SET DISPLAY TO &lc_display.      && Reset Screen size if changed
  122. ENDIF
  123.  
  124. /ºRELEASE WINDOWS 86 < ?
  125. 
  126. RELEASE /─ll_carry,lc_fields,lc_status
  127. /⌠
  128. ON KEY LABEL F1
  129. 0/¡ON KEY LABEL F2
  130. /LDO C_ ?)8S ?&& Close up Lookup Files
  131. SET PROCEDURE TO (lc_proc))8S ?&& Re-Establish any open procedure file
  132. RELEASE lc_proc
  133. IF TYPE( "ll_echo" ) = "L"
  134.   IF ll_echo
  135.     SET ECHO ON
  136.   ENDIF
  137. ENDIF
  138. IF ll_talk
  139.   SET TALK ON
  140. ENDIF
  141. *-- EOP: 83 ?FMT
  142. <<.╓:    "Jü8. 0[    'Jü8. /g    [    ]?Kü/ƒ@Kü?    SKü8. /£╖ü?     MKü8. /╛┤ü?.╞Jü??    "<<..:Kü/@Kü?    SKü8. /╖ü?     MKü8. 0,Jü?<<.á4:/₧49`@ 0L;96 ?PROCEDURE S_ ?
  143. *--------------------------------------------------------------------------------
  144. * DESCRIPTION
  145. *   Open data (.dbf) files for Lookup operations & faster processing
  146. *--------------------------------------------------------------------------------
  147.   PRIVATE lc_alias, ll_esc
  148.   ll_esc = SET( "ESCAPE" ) = "ON"
  149.   SET ESCAPE OFF
  150.   lc_alias = ALIAS())8S ?&& Capture current alias
  151.  
  152. j8F 8I 0E$    POPUPS87 8= 8.     22..3##/=$S9ôB 9k 8< 8- /4É:6É    A.ôS9≥B     S9╗C 8= <2╥.╫     ,%8. 0=$%    ,%  IF TYPE("g_8> ?") = "U"
  153.     PUBLIC g_8> ?
  154.  
  155.     IF SELECT("?") = 0
  156.       IF FILE( "?.DBF" )
  157.         SELECT SELECT()
  158.         USE ? NOLOG ALIAS ?
  159.         g_8> ? = 1)8S ?&& File was opened for the first time
  160.         IF TAGNO( "    ?" ) = 0
  161.           DO _Err_Box WITH [    ORDER TAG not found:? ] + [    ?]
  162.           USE
  163.           RELEASE g_8> ?
  164.           RELEASE gl_?
  165.           PUBLIC gl_?
  166.         ENDIF
  167.         IF TYPE( "?->?" ) = "U"
  168.           DO _Err_Box WITH [    Variable not found:? ] + [?->?]
  169.           USE
  170.           RELEASE g_8> ?
  171.           RELEASE gl_?
  172.           PUBLIC gl_?
  173.         ENDIF  
  174.       ELSE
  175.         DO _Err_Box WITH "?.DBF " + [    
  176. not found!?]
  177.         RELEASE g_8> ?
  178.         RELEASE gl_?
  179.         PUBLIC gl_?
  180.       ENDIF
  181.     ELSE
  182.       g_8> ? = 2)8S ?&& File was opened outside of this program
  183.     ENDIF
  184.  
  185.   ELSE
  186.     *-- File was already opened by a program generated from Form.gen
  187.     g_8> ? = g_8> ? + 1
  188.   ENDIF
  189.  
  190. ,.⌡  SELECT ( lc_alias )
  191.   IF ll_esc
  192.     SET ESCAPE ON
  193.   ENDIF
  194. RETURN
  195. *-- EOP: S_ ?
  196.  
  197.  
  198. PROCEDURE C_ ?
  199. *--------------------------------------------------------------------------------
  200. * DESCRIPTION
  201. *   Close Lookup files on exit of the .fmt, if they are not used
  202. *   by other calling .fmt files
  203. *--------------------------------------------------------------------------------
  204.   PRIVATE ll_esc
  205.   ll_esc = SET( "ESCAPE" ) = "ON"
  206.   SET ESCAPE OFF
  207.     %j8F 8I 0²'    POPUPS87 8= 8.     22S&.X&##/⌡'S9ôB 8< 8- /4»&:6»&    A.▓&    ,%8. 0⌡'%    ,%  DO CASE
  208.     CASE TYPE("g_8> ?") = "U"
  209.       *-- Exiting out of the form!  Lookup file was not opened up properly
  210.       RELEASE gl_?
  211.     CASE g_8> ? = 1
  212.       USE IN ?
  213.       RELEASE g_8> ?
  214.     OTHERWISE
  215.       g_8> ? = g_8> ? - 1
  216.   ENDCASE
  217. ,.&
  218.   IF ll_esc
  219.     SET ESCAPE ON
  220.   ENDIF
  221. RETURN
  222. *-- EOP: C_ ?
  223.  
  224. j8F 8I 0é4    POPUPS87 8= 8.     22Ü(.ƒ(#9╤A#/z4ß9₧ !]9₧ "S9ôB 8< 8- /4"):6")    A.%)S9≥B     S9╗C ½W9┐9 &    9&9 /z4FUNCTION =9╨D ?
  225. PARAMETER fld_name
  226. *    -E8V ?
  227.   PRIVATE ALL LIKE l?_*
  228.   PRIVATE esckey, fld_name, rtn_fld
  229.   ll_esc = SET( "ESCAPE" ) = "ON"
  230.   SET ESCAPE OFF
  231.   ll_return = .F.
  232.   IF TYPE( "gl_?" ) = "L")8S ?&& Was lookup file opened?
  233.     IF ll_esc)8S ?&& It wasn't, so return back to the form
  234.       SET ESCAPE ON
  235.     ENDIF
  236.     RETURN(.T.))8S ?&& With no data validation
  237.   ENDIF
  238. S9÷D 0π+  IF ISBLANK(fld_name))8S ?&& Not a required field
  239.     IF ll_esc
  240.       SET ESCAPE ON
  241.     ENDIF
  242.     RETURN (.T.))8S ?&& Return since it's a blank field
  243.   ENDIF
  244.  
  245.   EscKey = 27)8S ?&& 27 represents the ESC key
  246.  
  247.   lc_alias = ALIAS())8S ?&& Grab current workarea
  248.   SELECT ?)8S ?&& Select the lookup file
  249.   lc_order = ORDER())8S ?&& Save any existing order
  250.   SET ORDER TO     ?)8S ?&& Set the order to the lookup key
  251.  
  252.   ll_exact = SET("EXACT") = "ON")8S ?&& Store value of EXACT
  253.   SET EXACT ON
  254.  
  255. @80     C2╜-  fld_name = IIF( ISBLANK( TRIM( fld_name)), fld_name, TRIM( fld_name))
  256.   SEEK fld_name
  257.  
  258.   IF .NOT. ll_exact)8S ?&& Restore SET EXACT to org. value
  259.     SET EXACT OFF
  260.   ENDIF
  261.  
  262.   IF .NOT. FOUND()
  263.  
  264.     DEFINE POPUP S9 D ? FROM !6┴.!?,"? ;
  265.         TO ?,J86" ? ;
  266. . /! ?,"? ;
  267.         TO !?,J86" ? ;
  268.         PROMPT FIELD ? ;
  269.         MESSAGE     8[Press the Enter key to select or the Esc key to cancel]?
  270.  
  271.     ON SELECTION POPUP S9 D ? DEACTIVATE POPUP
  272.  
  273. @80     C2σ/    KEYBOARD TRIM(fld_name)
  274.     SAVE SCREEN TO temp
  275. S9UE /ä0    5Shadow coordinates exceed column 79 - move field left9&9 /ä0    DO shadowg WITH J9KD
  276.  
  277.     ACTIVATE POPUP S9 D ?
  278.  
  279.     rtn_fld = PROMPT())8S ?&& Get user choice from pick list
  280.     ln_bar = BAR())8S ?&& Capture bar number to check for esc
  281.  
  282.     RELEASE POPUP S9 D ?
  283.  
  284.     RESTORE SCREEN FROM temp
  285.  
  286.     IF ln_bar <> 0
  287.       @ !?,"? GET rtn_fld 9ß8 /╫1PICTURE 92 9┐< ?
  288.       CLEAR GETS
  289.  
  290.       REPLACE <9k ?->=9k ? WITH @80     C2C2rtn_fld
  291. .R2VAL(rtn_fld)
  292. 
  293.       ll_return = .T.
  294.     ELSE
  295.       ll_return = .F.
  296. S9÷D 0 3      IF ISBLANK(fld_name))8S ?&& Not a required field, so return
  297.         ll_return = .T.
  298.       ENDIF
  299.  
  300.     ENDIF
  301.  
  302.   ELSE
  303.     ll_return = .T.
  304.   ENDIF
  305.  
  306.   IF .NOT. ISBLANK( lc_order ))8S ?&& If there was a order on lookup file
  307.     SET ORDER TO ( lc_order ))8S ?&& Set it back to its original setting
  308.   ENDIF
  309.  
  310.   SELECT (lc_alias))8S ?&& Go back to the edit file
  311.  
  312.   IF ll_esc
  313.     SET ESCAPE ON
  314.   ENDIF
  315. RETURN (ll_return)
  316. *-- EOP: =9╨D ?
  317.  
  318. ,.a(    -N8V    * 8B
  319. <<.Σ4:/╧40╩49`@ 0┼4;969╝X0▌4/Γ49║E<<.6:83 86 8<     .2<5<     .FMT.I5    .FMT*    -E8V ?
  320. * Name.......: ?
  321. * Date.......: 8M 8< 87 ?
  322. * Version....: dBASE IV, Format     2.0?
  323. * Notes......: Format files use "" as delimiters!
  324. *    -E8V ?
  325. <.▌8:83 86 8<     .2e6<     .FMT.r6    .FMT*    -E8V ?
  326. * Name....: U_(8< 88 ?.PRG
  327. * Date....: 8M 8< 87 ?
  328. * Version.: dBASE IV, Procedure for Format     2.0?
  329. * Notes...: Procedure file for VALID POPUPs and/or Context Sensitive Help
  330. *           for ?
  331. $/╜7*           The Master file for the form is assumed to be $?.
  332. *    -E8V ?
  333. 8P ?PRIVATE ll_oldtalk
  334. IF SET( "TALK" ) = "ON"
  335.   SET TALK OFF
  336.   ll_oldtalk = .T.
  337. ELSE
  338.   ll_oldtalk = .F.
  339. ENDIF
  340.  
  341. *--     Can't run a procedure file!?
  342. DO _Err_Box WITH "    Can't run a procedure file!?"
  343.  
  344. IF ll_oldtalk
  345.   SET TALK ON
  346. ENDIF
  347. 8P ?RETURN
  348.  
  349.  
  350. <."9:Jü/@ü80     D1@ü80     M1;;<.╗9:]ü9₧ Jü86 P4┤9/«9908o
  351. =ü    Error on Field: =9░ 9░    Press any key ...8N;;<.^<:    Ç!!!0∙9!/·9p!!!!0T</J:>1√:1√:.╝:    n.≈:    b.≈:    g.≈:    bg.≈:    r.≈:    rb.≈:    gr.≈:    w.≈:7i:s:}:ç:Æ:£:º:▓:.;    w>/;    i>/);    u>/<;    +>/O;    *>    /1*<1*<.δ;    n.&<    b.&<    g.&<    bg.&<    r.&<    rb.&<    gr.&<    w.&<7x;å;ö;ó;▒;┐;╬;▌;.6<    n>/T</T<    ,>8T ;<.╗<:.₧<     .╢<     DOUBLE .╢<     CHR(    ) .╢<7l<v<ç<;<.=:    &86 4=/÷<    ;8U >    COLOR &     >;<.Ç=:    wndow     FROM 9ä= áüíü9b< ½üWü9┐9 &9┐< ;<.Ç>:úü9₧ ßü9₧ óü9₧ ¬ü/⌠=1⌠=    ,     TO Ñü=4Z>    ,ñü=;<.ò?:    j8F 8I 0ä?X/|?=    ,86 =    ,86             Φ4?    SET CARRY TO 8B    >K4D?    ;      8B>=9k 0o?8B.{?    ,8B >,.¿>         ADDITIVE8B<<.\@: 8l *(8Y 0σ?0╘?(.Σ?    :(>    .fmt8C 0U@82     .fmt    - can't be opened - possible read only file.      Press any key ...8N;;<.A:*    u_(8< 88     .prg8C 0≤@    .prg    - can't be opened - possible read only file.      Press any key ...8N;    .DBO8{;<.mA:j8F 8I 0hA    POPUPS87 8= 8.     22`A.hA,.$A;<.═A:82 8<*     _H      .dbf8W /╚A     .dbt8W /╚A>;<.)B:ßü9₧ 4"B;;<.ÅB:8= 8. 2XB    ;< 86 86 8< ;<.εB:    ->    =9-B 8/ 8. < 9k ;<.╖C:    ORDER 9-B      8. 2OC86 < .½C    "8. 1æC6æC< .½C< >9k ;<.D:    ->9-B      8. 2°C.D< 9k ;<.GD:9╗C 8<    u_ 8> ;<.╠D:!6ôD!?,"?,?,86" ?
  352. .╩D! ?,"?,!?,86" ?
  353. <<.≥D:8<    u_ 9k ;<.QE:     REQ 8= 8. /E.E0ME     REQ"8= 8. /DE.IE/NE;<.╢E:     SHADOW 8= 8. /|E.üE0▓E     SHADOW"8= 8. /⌐E.«E/│E;<.₧G:PROCEDURE Shadowg
  354. *    -E8V ?
  355. * DESCRIPTION
  356. *   Displays shadow that grows.  Specify the same coord and the
  357. *   window or popup to shadow.
  358. *    -E8V ?
  359.   PARAMETER x1,y1,x2,y2
  360.   PRIVATE   x1,y1,x2,y2
  361.  
  362.   x0 = x2+1
  363.   y0 = y2+2
  364.   dx = 1
  365.   dy = (y2-y1) / (x2-x1)
  366.   DO WHILE x0 <> x1 .OR. y0 <> y1+2
  367.     @ x0,y0 FILL TO x2+1,y2+2 COLOR n+/n
  368.     x0 = IIF(x0<>x1,x0 - dx,x0)
  369.     y0 = IIF(y0<>y1+2,y0 - dy,y0)
  370.     y0 = IIF(y0<y1+2,y1+2,y0)
  371.   ENDDO
  372.  
  373. RETURN
  374. *-- EOP: shadowg
  375.  
  376. <<.╕X:PROCEDURE _Err_Box
  377. PARAMETERS pc_msg
  378. *----------------------------------------------------------------------------
  379. * NAME
  380. *   _Err_Box - Display an error box
  381. *
  382. * SYNOPSIS
  383. *   DO _Err_Box WITH <pc_msg>
  384. *
  385. * DESCRIPTION
  386. *   _Err_Box will display the <pc_msg> string in a box and prompt the
  387. *   user to press any key to continue processing.  _Err_Box will display
  388. *   the message based on the length of <pc_msg>.
  389. *
  390. * PARAMETERS
  391. *   pc_msg - the error message to display in the box.  If the length is
  392. *            greater than 76, the trailing part is chopped off.
  393. *
  394. * EXAMPLE
  395. *   DO _Err_Box WITH "Incorrect window size"
  396. *   Displays the message in a window as follows at row 9 on the screen:
  397. *                      +------------------------------+
  398. *                      |                              |
  399. *                      |    Incorrect window size     |
  400. *                      |                              |
  401. *                      | Press any key to continue... |
  402. *                      |                              |
  403. *                      +------------------------------+
  404. *   Note that the width of the window will increase to accommodate a longer
  405. *   message string.
  406. *
  407. * LIMITATIONS
  408. *   Truncates the message after 76 characters.  Assumes an 80 character
  409. *   wide screen.  Looks best with SET CURSOR OFF.
  410. *
  411. *----------------------------------------------------------------------------
  412.  
  413.   PRIVATE lc_anykey, lc_msg, lc_msglen, lc_win, ln_press, ln_width, ll_trap,;
  414.           ll_escape
  415.  
  416.   lc_anykey = [Press any key to continue...]
  417.   ln_press  = LEN( lc_anykey )
  418.   lc_win = WINDOW()                     && Currently activated window if any
  419.   lc_msg = LTRIM( RTRIM( pc_msg ) )     && Trimmed message
  420.   ln_msglen = LEN( lc_msg )             && Trimmed length of message
  421.   ln_width = 0                          && Width of display area in window.
  422.   ll_escape = SET("ESCAPE") = "ON"
  423.   IF TYPE( "FXL_DEV" ) = "L" .AND. FXL_DEV
  424.     SET ESCAPE ON
  425.   ELSE
  426.     SET ESCAPE OFF
  427.   ENDIF
  428.  
  429.   *-- Determine the width needed for the window:
  430.   IF ln_msglen <= ln_press
  431.     ln_width = ln_press
  432.   ELSE
  433.     *-- Make sure the message fits in the window:
  434.     IF ln_msglen > 76
  435.       lc_msg = LEFT( lc_msg, 76 )
  436.       ln_msglen = 76
  437.     ENDIF
  438.     ln_width = ln_msglen
  439.   ENDIF
  440.   DEFINE WINDOW _err_box FROM 9, ((76 - ln_width) + .5) / 2 ;
  441.                 TO 15, (ln_width + 83) / 2 DOUBLE
  442.   ln_width = ( ln_width + 2 )
  443.  
  444.   *-- Display the message and prompt to the window and wait for a key press
  445.   ACTIVATE WINDOW _err_box
  446.   @ 1, ( ln_width - ln_msglen ) / 2 SAY lc_msg
  447.   @ 3, ( ln_width - ln_press ) / 2 SAY lc_anykey
  448.   SET CONSOLE OFF                       && For mouse click recognition
  449.   WAIT
  450.   SET CONSOLE ON
  451.  
  452.   *-- Clean up the window display and reactivate the previous window
  453.   RELEASE WINDOW _err_box
  454.   IF ISBLANK( lc_win )
  455.     ACTIVATE SCREEN
  456.   ENDIF
  457.  
  458.   IF ll_escape
  459.     SET ESCAPE ON
  460.   ELSE
  461.     SET ESCAPE OFF
  462.   ENDIF
  463.  
  464. RETURN
  465. *-- EOP: _Err_Box WITH pc_msg
  466.  
  467.  
  468. FUNCTION _Rat
  469. PARAMETERS pc_source, pc_target
  470. *--------------------------------------------------------------------
  471. * NAME
  472. *   _RAT - Version of AT() that starts from right.
  473. *
  474. * SYNOPSIS
  475. *   _RAT( <expC>, <expC> )
  476. *
  477. * DESCRIPTION
  478. *   _RAT() takes two arguments, a source string and a target
  479. *   string.  It searches for the first occurrence of the source
  480. *   within the target beginning on the right end of the string,
  481. *   and returns an integer representing the first character
  482. *   position of the matching occurrence.
  483. *
  484. *   If the source string is not contained within the target
  485. *   string, if the source string is longer than the target
  486. *   string, or if the source string is null, 0 is returned.
  487. *
  488. * PARAMETER(S)
  489. *   The first parameter is the string to find.  The second
  490. *   parameter is the string to search in.  In theory, any
  491. *   character expression should be legal.
  492. *
  493. * EXAMPLE(S)
  494. *
  495. *   ? _RAT("A","ABABA")                      && Returns 5
  496. *   lc_var = _RAT("A test","A test A test")  && Returns 8
  497. *   ? _RAT("Long string","short")            && Returns 0
  498. *
  499. *--------------------------------------------------------------------
  500.  
  501.    PRIVATE lc_len
  502.  
  503.    m->lc_len = LEN( m->pc_target )
  504.  
  505.    DO WHILE m->lc_len > 0
  506.      IF m->pc_source $ SUBSTR(m->pc_target, m->lc_len)
  507.        EXIT
  508.      ELSE
  509.        m->lc_len = (m->lc_len - 1)
  510.      ENDIF
  511.    ENDDO
  512.  
  513.    RETURN m->lc_len
  514.  
  515. *-- EOF: _Rat( pc_source, pc_target )
  516.  
  517. <<.╫h:PROCEDURE Help
  518. PARAMETER lc_var
  519. *    -E8V ?
  520. * DESCRIPTION
  521. *   Activates the HELP window
  522. *    -E8V ?
  523. 8P ?PRIVATE ALL LIKE ??_*
  524. ON KEY LABEL F1)8S ?&& Dsiable the F1 key during help
  525. IF .NOT. FILE(" 82 ?.dbf")
  526.   *-- Help file has been deleted or can't be found
  527.   DO _Err_Box WITH "    Help file no longer exists: ?" + " 82 ?.dbf"
  528.   RETURN
  529. ENDIF
  530. ll_cat = SET( "CATALOG" ) = "ON"
  531. SET CATALOG OFF
  532.  
  533. SET CURSOR OFF
  534.  
  535. *-- Select workarea and open Help dbf
  536. lc_area = ALIAS()
  537.  
  538. *-- Open the HELP dbf file for the form
  539. SELECT SELECT()
  540. USE  82 ? ORDER fld_name NOUPDATE NOLOG
  541.  
  542. ll_exact = SET("EXACT") = "ON"
  543. SET EXACT ON
  544. SEEK lc_var)8S ?&& Search for the field name in help
  545. IF .NOT. ll_exact
  546.   SET EXACT OFF
  547. ENDIF
  548. IF FOUND()
  549.   *-- Define the coord for the help window
  550.   ln_t = 5
  551.   ln_l = 6
  552.   ln_b = 15
  553.   ln_r = 74
  554.   ON KEY LABEL F3 DO Toggle
  555.   DEFINE WINDOW z_help FROM ln_t+1, ln_l+2 TO ln_b-1, ln_r-2 NONE
  556.   ON ERROR lc_error=error()
  557.   SAVE SCREEN TO zz_help
  558.  
  559.   *-- Make Help Box
  560.   DO shadowg WITH ln_t, ln_l, ln_b, ln_r
  561.   @ ln_t+1, ln_l+1 CLEAR TO ln_b-1, ln_r-1
  562.   @ ln_t, ln_l TO ln_b, ln_r DOUBLE
  563.  
  564.   ln_memline = SET("MEMO")
  565.   SET MEMOWIDTH TO 65
  566.   IF MEMLINES(fld_help) > 9
  567.     @ ln_t+1,ln_r SAY CHR(24)
  568.     @ ln_b-1,ln_r SAY CHR(25)
  569.   ENDIF
  570.   lc_string = CHR(185)+ [ Help for ] + TRIM(fld_headng) +[ ] + CHR(204)
  571.   lc_message = IIF(MEMLINES(fld_help) > 9, ;
  572.                   "    NScroll thru Help: Ctrl-Home   Exit Viewing Help: Esc   See Original Screen: F3?", ;
  573.                   "    See Original Screen: F3?" ;
  574.                   )
  575.  
  576.   @ ln_t,CENTER(lc_string,80) SAY lc_string
  577.   @ 0,0 GET fld_help OPEN WINDOW z_help MESSAGE lc_message
  578.   READ
  579.   SET MEMOWIDTH TO ln_memline
  580.   ON ERROR
  581.   ON KEY LABEL F3
  582.   RELEASE WINDOW z_help
  583.   RESTORE SCREEN FROM zz_help
  584.   RELEASE SCREEN zz_help
  585. ELSE
  586.   DO _Err_Box WITH [    (There is no help defined for this field:? ] + lc_var
  587. ENDIF
  588. SET MESSAGE TO
  589. IF ll_cat
  590.   SET CATALOG ON
  591. ENDIF
  592. SET CURSOR ON
  593. USE)8S ?&& Close help file
  594. SELECT (lc_area))8S ?&& Back to edit work area
  595. ON KEY LABEL F1 DO Help WITH VARREAD()
  596. 8P ?RETURN
  597. *-- EOP: HELP
  598.  
  599.  
  600. PROCEDURE Toggle
  601. *    -E8V ?
  602. * DESCRIPTION
  603. *   Toggles the Help message back to the original screen
  604. *    -E8V ?
  605. 8P ?PRIVATE ll_cons
  606. SAVE SCREEN to Toggle
  607. RESTORE SCREEN FROM zz_help
  608. SET MESSAGE TO "Press any key..."
  609. ll_cons = SET( "CONSOLE" ) = "ON"
  610. SET CONSOLE OFF
  611. WAIT
  612. IF ll_cons
  613.   SET CONSOLE ON
  614. ENDIF
  615. RESTORE SCREEN FROM Toggle
  616. RELEASE SCREEN Toggle
  617. SET MESSAGE TO "Scroll thru Help: Ctrl-Home   Exit Viewing Help: Ctrl-End   See Org. Screen: F3"
  618. 8P ?RETURN
  619. *-- EOP: Toggle
  620.  
  621.  
  622. FUNCTION Center
  623. PARAMETER lc_string, ln_width
  624. *    -E8V ?
  625. * NAME
  626. *   Center() - Provide column needed to center a string in a width
  627. *
  628. * DESCRIPTION 
  629. *   The CENTER() function will return the starting column 
  630. *   coordinate to center the <lc_string> string within a width of 
  631. *   screen <ln_width>.  The width of the screen would normally be 
  632. *   80 colunms, but could just as well be the width of a window.  
  633. *   If there is an error condition, the returned result will equal 0.
  634. *   If a numeric value is passed for the <expC> value, it will be 
  635. *   converted to a string.
  636. * EXAMPLES
  637. *   @ 15,center(string,80) say string    
  638. *   Will center the <string> withing 80 columns
  639. *-----------------------------------------------------------------------------
  640.   PRIVATE lc_result, lc_type
  641.  
  642.   IF .NOT. TYPE("ln_width") $ "FN")8S ?&& Force value to 0 for bad type
  643.     lc_result = 0
  644.   ELSE
  645.  
  646.     lc_type = TYPE("lc_string")
  647.     DO CASE
  648.       CASE lc_type = "C"
  649.         lc_width = (ln_width/2)-(LEN(lc_string)/2)
  650.       CASE lc_type $ "NF"
  651.         lc_width = (ln_width/2)-(LEN(ALLTRIM(STR(lc_string)))/2)
  652.       CASE lc_type = "L"
  653.         lc_width = (ln_width/2)-(1.5))8S ?&& .T. or .F. have fixed len of 3
  654.       OTHERWISE                          
  655.         lc_width = 0
  656.     ENDCASE
  657.   ENDIF
  658.   
  659.   IF lc_width < 0)8S ?&& Force negative values to 0
  660.     lc_width = 0
  661.   ENDIF
  662.  
  663. RETURN ( lc_width )
  664. *-- EOF: Center( lc_string, ln_width )
  665.  
  666. <<.½q:*-- Set procedure to the lookup programs
  667. ll_echo = SET( "ECHO" ) = "ON"
  668. SET ECHO OFF
  669.  
  670. lc_proc = SET("procedure"))8S ?&& Store procedure file name
  671. IF FILE(" 9k ?.prg") .OR. FILE(" 9k ?.dbo")
  672.   SET PROCEDURE TO  9k ?
  673. ELSE
  674.   lc_fullpath = SET("FULLPATH")
  675.   SET FULLPATH ON
  676.   lc_setfmt = SET("FORMAT")
  677.  
  678.   *-- Pull out the file path from the format file for a prefix
  679.     lc_slash = IIF( LEFT( OS(), 3 ) = "DOS", "\", "/" )
  680.  
  681.     *-- Look for last slash in the string
  682.     m->lc_len = LEN( lc_setfmt )
  683.     DO WHILE m->lc_len > 0
  684.       IF m->lc_slash $ SUBSTR(m->lc_setfmt, m->lc_len)
  685.         EXIT
  686.       ELSE
  687.         m->lc_len = m->lc_len - 1
  688.       ENDIF
  689.     ENDDO
  690.  
  691.   lc_fullnam = LEFT( lc_setfmt, m->lc_len ) + " 9k ?"
  692.   IF FILE( lc_fullnam + ".prg" ) .OR. FILE( lc_fullnam + ".dbo" )
  693.     SET PROCEDURE TO ( lc_fullnam )
  694.   ELSE
  695.  
  696.     *-- Display the error message in a windowed box
  697.     PRIVATE lc_anykey, lc_msg, lc_msglen, lc_win, ln_press, ln_width, ll_trap,;
  698.             ll_escape
  699.  
  700.     lc_anykey = [Press any key to continue...]
  701.     ln_press  = LEN( lc_anykey )
  702.     lc_msg = "    Procedure library?  9k ?     
  703. not found!?"
  704.     ln_msglen = LEN( lc_msg )
  705.     ln_width = 0
  706.     ll_escape = SET("ESCAPE") = "ON"
  707.     SET ESCAPE OFF
  708.  
  709.     *-- Determine the width needed for the window:
  710.     IF ln_msglen <= ln_press
  711.       ln_width = ln_press
  712.     ELSE
  713.       *-- Make sure the message fits in the window:
  714.       IF ln_msglen > 76
  715.         lc_msg = LEFT( lc_msg, 76 )
  716.         ln_msglen = 76
  717.       ENDIF
  718.       ln_width = ln_msglen
  719.     ENDIF
  720.     DEFINE WINDOW _err_box FROM 9, ((76 - ln_width) + .5) / 2 ;
  721.                   TO 15, (ln_width + 83) / 2 DOUBLE
  722.     ln_width = ( ln_width + 2 )
  723.  
  724.     *-- Display the message and prompt to the window and wait for a key press
  725.     ACTIVATE WINDOW _err_box
  726.     ? lc_msg AT ( ln_width - ln_msglen ) / 2 
  727.     ?
  728.     ? lc_anykey AT ( ln_width - ln_press ) / 2 
  729.     SET CONSOLE OFF
  730.     WAIT
  731.     SET CONSOLE ON
  732.  
  733.     *-- Clean up the window display and reactivate the previous window
  734.     RELEASE WINDOW _err_box
  735.  
  736.     IF ll_escape
  737.       SET ESCAPE ON
  738.     ELSE
  739.       SET ESCAPE OFF
  740.     ENDIF
  741.  
  742.   ENDIF
  743.  
  744.   IF lc_fullpath = "OFF"
  745.     SET FULLPATH OFF
  746.   ENDIF
  747.  
  748. ENDIF)8S ?&&   UDF's won't run
  749.  
  750. <<.ir:.)r    MONO.dr    COLOR.dr    EGA25.dr    MONO43.dr    EGA43.dr    VGA25.dr    VGA43.dr    VGA50.dr7╣q╞q╘qΓq±q qrr;<.ƒs:╡ &/ör    
  751. lc_display.ár    
  752. gc_display9»q     508. /╫rSET DISPLAY TO VGA50
  753. .¥s    438. /¥s*-- If not already in 43 line mode, set it based on MONO or EGA
  754. IF .NOT. "43" $ ?
  755.   IF "MONO" $ ?
  756.     SET DISPLAY TO MONO43
  757.   ELSE
  758.     SET DISPLAY TO EGA43
  759.   ENDIF
  760. ENDIF
  761. <<.    t:8k 1╫s1╫s2Σs'.t2²s..t><<
  762. <