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