home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / popcalc7.zip / POPCALC7.PRG < prev   
Text File  |  1990-12-19  |  42KB  |  1,302 lines

  1. ** Program : PopCalc7.prg
  2. ** Purpose : Pop-up Calculator 
  3. ** dBASE   : dBASE IV version 1.1
  4. ** Written : 05/10/89
  5. ** Author  : Richard Price ... ATBBS:  HAMMETT
  6. **                         ... CIS:    71157,762
  7. ** Revised : 05/10/89 - PopCalc3 ... Tape and Paste
  8. **         : 06/13/89 - PopCalc4 ... Added shadowing.
  9. **         : 08/08/90 - PopCalc5 ... Moving Windows.
  10. **         : 12/12/90 - PopCalc6 ... Renamed variables
  11. **                      using standardized conventions.
  12. **                      Modified shadow effects.
  13. **                      Removed all @..GET/READS.
  14. **                      Instigated use of a memory file.
  15. **                      Re-configurable at runtime.
  16. **                      Exploding Windows/Shadows.
  17. **                      Opaque or transparent shadows
  18. **                      provided for move/nomove 
  19. **                      windowing capabilities.
  20. **                      Modified to run from within
  21. **                      any dB4 1.1 application without
  22. **                      changes to either PopCalc7
  23. **                      or the calling program.
  24. **         : 12/17/90   PopCalc7 ... Renamed to avoid 
  25. **                      confusion with PopCalc6.ZIP on
  26. **                      the BBS's
  27. **                      Added UDF TrimZero() to trim 
  28. **                      trailing 0's and decimal point
  29. **                      from numbers passed by paste
  30. **                      routines.
  31.  
  32. **           All user input in PopCalc7 is via INKEY(0).
  33. **           Processing is based upon either its ASCII value 
  34. **           or its string representation. 
  35. **           Processing the calculator's inkey(0) and 
  36. **           chr(inkey()) is as follows:
  37.  
  38. **              Key       ACTION
  39. **            -------  ---------------------------------
  40. **              0-9    Numerical input.
  41. **               .         "       "
  42. **               M     Activate Memory Processing
  43. **               T     Activate Tape Display
  44. **               P     Activate Paste Display
  45. **               C     Clear current entry and answer,
  46. **                     and reset operators
  47. **               E     Clear current entry only.
  48. **               +     Add
  49. **               -     Subtract
  50. **               /     Division
  51. **               *     Multiplication
  52. **               ^     Exponentiation
  53. **               =     Provides total/clears operator.
  54. **             ENTER   Same as =
  55. **               R     "R"econfigure PopCalc7 options.
  56. **                     Opens a dialog box to enable/
  57. **                     disable Shadow Windows, Window 
  58. **                     Movement, Exploding Opening 
  59. **                     Window, and resetting the tape 
  60. **                     size.
  61. **               F1    HELP
  62.  
  63. **           Processing from within Memory mode follows:
  64.  
  65. **              Key        ACTION
  66. **            -------  ---------------------------------
  67. **                R    Recall value held in Memory 
  68. **                C    Clear Memory 
  69. **                +    Add to Memory
  70. **                -    Subtract from Answer
  71. **                /    Divide memory
  72. **                *    Multiply memory
  73. **                ^    Exponentiate memory
  74. **                =    Provides a total and clears the
  75. **                     memory operator.
  76. **               F1    HELP
  77.  
  78. ** NOTE: Memvars which will be saved to PopCalc7.MEM
  79. **       are designated as m<type>_
  80. **       ml_<name> = logical memvars
  81. **       mn_<name> = numerical memvars
  82. **       mc_<name> = character memvars
  83. **       ma_<name> = array memvars
  84.  
  85. **    There are four (4) "configuration" memvars 
  86. **    which the user may change from within PopCalc7.
  87. **    ml_Shadow  = .t. for shadow usage
  88. **    ml_Explode = .t. for exploding windows
  89. **    ml_Move    = .t. enables moving windows.
  90. **    mn_TapeSiz = Number used to declare the
  91. **                 tape array.
  92. **    These memvars can be changed by pressing
  93. **    "R" while in the main calculator window.
  94.  
  95. **    NOTE:  If movement is not enabled, then
  96. **           shadowing routine is different.
  97. **           In order to move windows with shadows,
  98. **           the shadow must be in the form of
  99. **           a window, and the shadow is opaque
  100. **           and the underlying screen is hidden.
  101. **
  102. **           If movement is disabled, then the
  103. **           shadow can be transparent, and the
  104. **           underlying screen will be dimmed,
  105. **           but visible.
  106. **           All shadowing will be exploded,
  107. **           when shadowing is enabled.
  108.  
  109. **    WHY?   Because I like it that way! 
  110.  
  111.  
  112. PROCEDURE PopCalc7
  113. **       Save the current screen and activate.
  114. SAVE SCREEN TO POPSCR_1
  115. ACTIVATE SCREEN
  116. **       Save and set the environment.
  117. IF SET("TALK")="ON"
  118.    SET TALK OFF
  119.    lc_PCTalk = "ON"
  120. ELSE
  121.    SET TALK OFF
  122.    lc_PCTalk = "OFF"
  123. ENDIF
  124. ll_PCStat = (SET("STATUS")="ON")
  125. lc_PCBell  = SET("BELL")
  126. lc_PCEsc   = SET("ESCAPE")
  127. lc_PCDelim = SET("DELIMITER")
  128. lc_PCCurs  = SET("CURSOR")
  129. SET BELL OFF
  130. SET ESCAPE OFF
  131. SET DELIMITERS OFF
  132. SET CURSOR OFF
  133. SET BORDER TO
  134. IF TYPE("gc_PopCalc")="U".OR..NOT.FILE("PopCalc7.MEM")
  135.    PUBLIC gc_PopCalc
  136.    STORE .t. TO ml_Shadow, ml_Move
  137.    STORE .f. TO ml_Explode
  138.    STORE 0 TO mn_CalcAns, mn_Mem, mn_TapeCnt
  139.    STORE 0 TO mn_TapeNum, mn_TapeEnd
  140.    ** PCW.... (P)op (C)alc6 (W)indow settings
  141.    mn_PCWRow1 = 1
  142.    mn_PCWCol1 = 24
  143.    mn_PCWRow2 = 16
  144.    mn_PCWCol2 = 53
  145.    ** PTW.... (P)op (T)ape (W)indow settings
  146.    mn_PTWRow1 = 3
  147.    mn_PTWCol1 = 49
  148.    mn_PTWRow2 = 20
  149.    mn_PTWCol2 = 68
  150.    mc_KeyStr  = " "
  151.    mc_Operatr = "+"
  152.    mc_Entry   = space(14)
  153.    mn_TapeSiz = 100
  154.    DECLARE ma_Tape[mn_TapeSiz,2]
  155.    DO TapeInit
  156. ELSE
  157.    RESTORE FROM PopCalc7 ADDITIVE
  158. ENDIF
  159. ll_Reset = .t.
  160. DO WHILE ll_Reset
  161.    ll_Reset = .f.
  162.    ll_ShadWin = (ml_Shadow .AND. ml_Move)
  163.    **    Display the calculator window.
  164.    DO CalcDisp
  165.    **    Obtain and process user input.
  166.    DO Calc_Key
  167.    **    Restore the screen
  168.    RESTORE SCREEN FROM POPSCR_1
  169. ENDDO
  170. **       Restore the working environment.
  171. RELEASE SCREEN POPSCR_1
  172. lc_PCSafe = SET("SAFETY")
  173. SET SAFETY OFF
  174. SAVE TO PopCalc7 ALL LIKE M?_*
  175. SET SAFETY &lc_PCSafe.
  176. SET BELL &lc_PCBell.
  177. SET DELIM &lc_PCDelim.
  178. SET CURSOR &lc_PCCurs.
  179. SET ESCAPE &lc_PCEsc.
  180. SET TALK &lc_PCTalk.
  181. RETURN
  182.  
  183. PROCEDURE CalcDisp
  184. **    Build the PopCalc7 calculator display.
  185. **    Specifying the color on the @ .. SAY lines is
  186. **    required due to a known dBASE IV 1.1 bug which,
  187. **    under certain circumstances, the default window
  188. **    colors are changed by the calling program.
  189. **    Also, I happen to like highlighting the
  190. **    available keys for display purposes.
  191.  
  192. **    Actually, the whole window PopCalc7 could be
  193. **    smaller and the only area one truly needs is
  194. **    the ANSWER line with possibly the MEMORY line
  195. **    added to view the current value held in MEMORY.
  196.  
  197. **    Verify Window Limits (and fix if necessary).
  198. **    REASON: If PopCalc7 was entered previously with
  199. **            shadowing disabled, AND window(s) were
  200. **            positioned on line 24, OR column > 78
  201. **            AND the next entry to PopCalc7 is with
  202. **            shadowing on, a window definition error
  203. **            would occur for the shadowing windows.
  204.  
  205. ln_MaxRow  = IIF(ll_PCStat,23,24) - ;
  206.    IIF(ml_Shadow,1,0)
  207.  
  208. ln_AdjWin  = ;
  209.    IIF(mn_PCWRow2>ln_MaxRow,mn_PCWRow2-ln_MaxRow,0)
  210.  
  211. mn_PCWRow1 = mn_PCWRow1 - ln_AdjWin
  212. mn_PCWRow2 = mn_PCWRow2 - ln_AdjWin
  213.  
  214. ln_AdjWin = ;
  215.    IIF(ml_Shadow,IIF(mn_PCWCol2>78,;
  216.    IIF(mn_PCWCol2=79,2,1),0),0)
  217.  
  218. mn_PCWCol1 = mn_PCWCol1 - ln_AdjWin
  219. mn_PCWCol2 = mn_PCWCol2 - ln_AdjWin
  220.  
  221. ln_AdjWin  = ;
  222.    IIF(mn_PTWRow2>ln_MaxRow,mn_PTWRow2-ln_MaxRow,0)
  223.  
  224. mn_PTWRow1 = mn_PTWRow1 - ln_AdjWin
  225. mn_PTWRow2 = mn_PTWRow2 - ln_AdjWin
  226.  
  227. ln_AdjWin = ;
  228.    IIF(ml_Shadow,IIF(mn_PTWCol2>78,;
  229.    IIF(mn_PTWCol2=79,2,1),0),0)
  230.  
  231. mn_PTWCol1 = mn_PTWCol1 - ln_AdjWin
  232. mn_PTWCol2 = mn_PTWCol2 - ln_AdjWin
  233.  
  234. RELEASE ln_AdjWin, ln_MaxRow
  235.  
  236. DEFINE WINDOW PopCalc7 ;
  237.    FROM mn_PCWRow1, mn_PCWCol1 ;
  238.    TO mn_PCWRow2,mn_PCWCol2 ;
  239.    DOUBLE color w+/rg,rg/rg,w+/rg
  240. DO CASE
  241.    CASE ml_Explode
  242.       **    Do an exploding window routine.
  243.       DO Exp_Main
  244.    CASE ml_Shadow
  245.       **    Provide an exploding shadow when
  246.       **    shadowing is enabled.
  247.       DO EXPSHADO with ;
  248.       mn_PCWRow1 , mn_PCWCol1, mn_PCWRow2,mn_PCWCol2
  249.       IF ml_Move
  250.          DEFINE WINDOW ShadCalc ;
  251.             FROM mn_PCWRow1 + 1, mn_PCWCol1 + 2 ;
  252.             TO mn_PCWRow2 + 1, mn_PCWCol2 + 2 ;
  253.             PANEL color w/n,w/n,n/w
  254.          DEAC WINDOW PopCalc7
  255.          RESTORE SCREEN FROM POPSCR_1
  256.          ACTIVATE SCREEN
  257.          ACTIVATE WINDOW ShadCalc
  258.       ENDIF
  259.       ACTIVATE WINDOW PopCalc7
  260.    OTHERWISE
  261.       ACTIVATE WINDOW PopCalc7
  262. ENDCASE
  263. @ 0,8 SAY "< PopCalc7 >" color rg+/RG
  264. @ 1,3 SAY "Entry :" color w+/RG
  265. @ 1,11 SAY mc_Entry pict "#########.####" color N/w
  266. @ 2,0 to 2,27 color w+/rg
  267. @ 3,3 SAY "Answer:" color w+/rg
  268. @ 3,11 SAY mn_CalcAns PICT "#########.####" color n/w
  269. @ 4,0 to 4,27 DOUB color w+/rg
  270. @ 4,3 SAY " Memory " color w+/rg
  271. @ 4,14 SAY "╤" color w+/rg  && CHR(209)
  272. @ 4,17 SAY " Numeric "color w+/rg
  273. @ 5,14 TO 11,14 color w+/rg
  274. @ 12,0 to 12,27 doub color w+/rg
  275. @ 12,14 SAY "╧" color w+/rg  && CHR(207)
  276. @ 8,0 TO 8,13 color w+/rg
  277. @ 8,14 SAY "┤" color w+/rg  && CHR(180)
  278. @ 8,4 SAY " Mem= " color w+/rg
  279. @ 9,0 SAY mn_Mem pict "@Z #########.####" color B/w
  280. @ 10,0 TO 10,13 color w+/rg
  281. @ 10,14 SAY "┤" color w+/rg  && CHR(180)
  282. @ 11,1 SAY "T" color n/w
  283. @ 11,2 SAY "ape" color w+/rg
  284. @ 11,6 SAY "I" color n/w
  285. @ 11,7 SAY "m" color w+/rg
  286. @ 11,8 SAY "P" color n/w
  287. @ 11,9 say "aste" color w+/rg
  288. @ 6,1 SAY "M" color b/w
  289. @ 5,4 SAY "R + - *" color n/w
  290. @ 7,4 SAY "C / ^" color n/w
  291. @ 5,5 fill to 7,5 color w/rg
  292. @ 5,7 fill to 7,7 color w/rg
  293. @ 5,9 fill to 7,9 color w/rg
  294. @ 5,17 SAY "= 7 8 9 -" color n/w
  295. @ 7,17 SAY "/ 4 5 6 +" color n/w
  296. @ 9,17 SAY "* 1 2 3 ^" color n/w
  297. @ 5,18 fill to 9,18 color w/rg
  298. @ 5,20 fill to 9,20 color w/rg
  299. @ 5,22 fill to 9,22 color w/rg
  300. @ 5,24 fill to 9,24 color w/rg
  301. @ 11,18 SAY " 0 " color n/w
  302. @ 11,22 SAY " . " color n/w
  303. @ 13,1 SAY "Esc" color n/w
  304. @ 13,5 say "R" color n/w
  305. @ 13,6 say "econfigure" color w+/rg
  306. @ 13,18 SAY "C" color n/w
  307. @ 13,21 SAY "C" color n/rg
  308. @ 13,22 SAY "E" color n/w
  309. @ 13,25 SAY CHR(17)+"┘" color n/w  && CHR(217)
  310. RETURN
  311.  
  312. PROCEDURE Calc_Key
  313. **    Loop thru calculator routine infinitly
  314. **    until <Esc> is pressed.
  315. DO WHIL .T.
  316.    lc_LastStr = mc_KeyStr
  317.    mc_KeyStr = " "
  318.    **    Re-initialize the TAPE array if needed.
  319.    IF mn_TapeNum = mn_TapeSiz
  320.       DO TapeInit
  321.    ENDI
  322.    **    Memvar mc_Entry is a string
  323.    **    representation of the numerical
  324.    **    value being entered.
  325.    @ 1,11 SAY mc_Entry color N/w
  326.    ln_CalcKey = inkey(0)
  327.    ln_CalcKey = IIF(ln_CalcKey=13,61,ln_CalcKey)
  328.    mc_KeyStr = UPPER(CHR(ln_CalcKey))
  329.    DO CASE
  330.       CASE ln_CalcKey = 27
  331.          **    Escape has been pressed (Exit PopCalc)
  332.          EXIT
  333.       CASE ln_CalcKey = 28
  334.          ** F1 - HELP
  335.          DO CalcHelp with 1
  336.          mc_KeyStr = lc_LastStr
  337.       CASE ln_CalcKey < 32 .AND. ml_Move
  338.          DO Move_Win with ln_Calckey, mn_PCWRow1,;
  339.             mn_PCWRow2, mn_PCWCol1, mn_PCWCol2
  340.          mc_KeyStr = lc_LastStr
  341.       CASE mc_KeyStr = "M"
  342.          @ 1,26 SAY "M" color w+/rg
  343.          @ 6,1 SAY "M" color W*/N
  344.          mc_KeyStr = UPPER(CHR(INKEY(0)))
  345.          IF mc_KeyStr $ "CR+-*/=^"
  346.             **    If there is a value displayed in the
  347.             **    ENTRY window, perform the requested 
  348.             **    operation using that value, else 
  349.             **    use the value held in ANSWER.
  350.             ln_CalcNum = IIF(lc_LastStr$".0123456789",;
  351.             VAL(mc_Entry),mn_CalcAns)
  352.             DO MathCalc ;
  353.                WITH mc_KeyStr, ln_CalcNum, mn_Mem
  354.             DO MemAns
  355.             mc_KeyStr = lc_LastStr
  356.          ELSE
  357.             ?? chr(7)
  358.          ENDIF
  359.          @ 6,1 SAY "M" color b/w
  360.          @ 1,26 SAY mc_Operatr color w+/rg
  361.       CASE mc_KeyStr="." .AND. "."$mc_Entry
  362.          **  Limit number to one decimal point.
  363.          ?? chr(7)
  364.          mc_KeyStr = lc_LastStr
  365.       CASE mc_KeyStr $ "0123456789."
  366.          **    A numerical type of entry was made.
  367.          **    Concatenate the string mc_KeyStr
  368.          **    to mc_Entry.
  369.          **    If maximum length (14) of mc_Entry
  370.          **    has been reached, beep and don't
  371.          **    concatenate
  372.          IF LEN(LTRIM(mc_Entry)) < 14
  373.             mc_Entry = RIGHT(mc_Entry,13) ;
  374.             + mc_KeyStr
  375.          ELSE
  376.             ?? CHR(7)
  377.          ENDIF
  378.          **    If the old operator was "=", reset
  379.          **    the Answer value to 0, increment the
  380.          **    tape counter, and update the tape.
  381.          IF mc_Operatr = "="
  382.             mn_TapeNum=mn_TapeNum+1
  383.             mc_Operatr="+"
  384.             mn_CalcAns=0
  385.          ENDIF
  386.       CASE ln_CalcKey = 127
  387.          **    BackSpace pressed.
  388.          **    Clear last keyed entry and delete
  389.          **    last number entered from mc_Entry.
  390.          mc_Entry = " " + LEFT(mc_Entry,13)
  391.          mc_KeyStr = " "
  392.       CASE mc_KeyStr = "=" .AND. mc_Operatr = "="
  393.          **    Enter or = has been keyed repeatedly.
  394.          **    No entry has been made, so reset the
  395.          **    operators to previous values and loop.
  396.          mc_KeyStr=lc_LastStr
  397.       CASE mc_KeyStr $ "+-/*^="
  398.          **    Perform the calculations,
  399.          **    update the operators and the tape.
  400.          @ 1,26 SAY mc_KeyStr color w+/rg
  401.          ln_CalcNum = VAL(mc_Entry)
  402.          **    Update tape to indicate that the next
  403.          **    value will be used in conjunction
  404.          **    with the value held in Answer
  405.          **    (mn_CalcAns) when the previous total
  406.          **    had been requested via the ENTER key
  407.          **    or "=" key, followed by an operator
  408.          **    (+-*/^) rather than a numerical entry.
  409.          IF ma_Tape[mn_TapeNum,1] = "=" ;
  410.             .AND. ma_Tape[mn_TapeNum,2] = 0 ;
  411.             .AND. mc_Operatr # "="
  412.             ma_Tape[mn_TapeNum,1] = " "
  413.             ma_Tape[mn_TapeNum,2] = mn_CalcAns
  414.          ENDIF
  415.          **    Increment and update the tape.
  416.          mn_TapeNum = mn_TapeNum + 1
  417.          ma_Tape[mn_TapeNum,1] = mc_Operatr
  418.          ma_Tape[mn_TapeNum,2] = ln_CalcNum
  419.          **    Perform the requested calculations.
  420.          DO MathCalc ;
  421.             WITH mc_Operatr, ln_CalcNum, mn_CalcAns
  422.          **    If ENTER or "=" has been pressed,
  423.          **    update the tape to show the answer.
  424.          IF mc_KeyStr="="
  425.             mn_TapeNum=mn_TapeNum+1
  426.             ma_Tape[mn_TapeNum,1]="="
  427.             ma_Tape[mn_TapeNum,2]=mn_CalcAns
  428.          ENDIF
  429.          **    Display the calculated answer.
  430.          DO CalcAns
  431.          **    Assign the math operator and clear
  432.          **    current entry string mc_Entry.
  433.          mc_Operatr=mc_KeyStr
  434.          mc_Entry=SPAC(14)
  435.       CASE mc_KeyStr = "I"
  436.          **    Exit PopCalc7 and KEYBOARD the answer
  437.          lc_CalcAns = ltrim(str(mn_CalcAns,14,4))
  438.          lc_CalcAns = TrimZero(lc_CalcAns)
  439.          KEYBOARD lc_CalcAns
  440.          EXIT
  441.       CASE mc_KeyStr = "R"
  442.          **  User wishes to reset PopCalc7 parameters
  443.          ll_reset = .f.
  444.          DO PC_Param with ll_reset
  445.          IF ll_reset
  446.             *  Parameters have changed, must exit
  447.             *  before new params take effect!
  448.             EXIT
  449.          ENDIF
  450.       CASE mc_KeyStr = "T"
  451.          **    Request Tape Viewing
  452.          DO TAPEDISP
  453.          mc_KeyStr = lc_LastStr
  454.       CASE mc_KeyStr = "P"
  455.          **    Request for Paste Function
  456.          DO PASTEVAL
  457.          mc_KeyStr = lc_LastStr
  458.       CASE mc_KeyStr = "E"
  459.          **    Clear the current entry only
  460.          mc_Entry=SPACE(14)
  461.          mc_KeyStr=lc_LastStr
  462.       CASE mc_KeyStr = "C"
  463.          **    Clear the current entry, answer, and
  464.          **    reset the associated memvars.
  465.          mc_KeyStr  = "="
  466.          mc_Operatr   = "+"
  467.          mc_Entry  = SPACE(14)
  468.          mn_CalcAns = 0
  469.          mn_TapeNum = mn_TapeNum + 1
  470.          ma_Tape[mn_TapeNum,1] = "C"
  471.          **    Now that the associated memvars are
  472.          **    cleared, refresh the display.
  473.          @ 1,26 SAY mc_KeyStr color w+/rg
  474.          DO CalcAns
  475.       OTHERWISE
  476.          mc_KeyStr = lc_LastStr
  477.    ENDCASE
  478. ENDDO
  479. RELEASE WINDOW PopCalc7
  480. IF ll_ShadWin
  481.    RELEASE WIND ShadCalc
  482. ENDIF
  483. RETURN
  484.  
  485. PROCEDURE MathCalc
  486. PARAMETERS OPERATOR, VALUE, ANSWER
  487. PRIVATE OPERATOR, VALUE, ANSWER
  488. **    Calculate the answer for main display
  489. **    and MEMORY display.
  490. DO CASE
  491.    CASE OPERATOR="+"
  492.       ANSWER = ANSWER + VALUE
  493.    CASE OPERATOR="-"
  494.       ANSWER = ANSWER - VALUE
  495.    CASE OPERATOR = "*"
  496.       ANSWER = ANSWER * VALUE
  497.    CASE OPERATOR="/"
  498.       ANSWER = ANSWER / FLOAT(VALUE)
  499.    CASE OPERATOR = "^" .AND..NOT. ;
  500.       (ANSWER<0 .AND. VALUE<1)
  501.       ANSWER = ANSWER ^ VALUE
  502.    CASE OPERATOR = "^" .AND. ;
  503.       (ANSWER<0 .AND. VALUE<1)
  504.       * Negative number to "root"
  505.       ?? chr(7)+chr(7)
  506.    CASE OPERATOR = "C"
  507.       ANSWER=0
  508.    CASE OPERATOR="R"
  509.       IF mc_Operatr = "="
  510.          mn_CalcAns = 0
  511.          mc_Operatr = "+"
  512.       ENDI
  513.       mc_Entry = STR(ANSWER,14,4)
  514. ENDCASE
  515. RETURN
  516.  
  517. PROCEDURE CalcAns
  518. **     Diplay the calculated answer
  519. DO CASE
  520.    CASE mn_CalcAns<0
  521.       **     Highlite if negative.
  522.       @ 3,11 SAY mn_CalcAns PICT "#########.####" ;
  523.       color R/w
  524.    OTHERWISE
  525.       @ 3,11 SAY mn_CalcAns PICT "#########.####" ;
  526.       color n/w
  527. ENDCASE
  528. RETURN
  529.  
  530. PROCEDURE MemAns
  531. **    Diplay the calculated Memory value
  532. DO CASE
  533.    CASE mn_Mem<0  && Highlite if negative.
  534.       @ 9,0 SAY mn_Mem pict "#########.####" ;
  535.       color R/w
  536.    OTHERWISE
  537.       @ 9,0 SAY mn_Mem pict "#########.####" ;
  538.       color B/w
  539. ENDCASE
  540. RETURN
  541.  
  542. PROCEDURE TapeInit
  543. ** INITIALIZE TAPE ARRAY
  544. mn_TapeNum = 0
  545. DO WHIL mn_TapeNum < mn_TapeSiz
  546.    mn_TapeNum = mn_TapeNum+1
  547.    ma_Tape[mn_TapeNum,1] = " "
  548.    STORE 0 TO ma_Tape[mn_TapeNum,2]
  549. ENDDO
  550. mn_TapeNum = 1
  551. mn_TapeCnt = 1
  552. RETURN
  553.  
  554. PROCEDURE Exp_Main
  555. **   Explode the main calculator window.
  556. **   (Explode its shadow if enabled)
  557. ln_Win_R1 = ;
  558.    INT((mn_PCWRow2-mn_PCWRow1)/2) + mn_PCWRow1
  559. ln_Win_R2 = ln_Win_R1+1
  560. ln_Win_C1 = ;
  561.    INT((mn_PCWCol2-mn_PCWCol1)/2) + mn_PCWCol1
  562. ln_Win_C2 = ln_Win_C1+1
  563. DO WHIL .t.
  564.    ln_Win_R1 = IIF(ln_Win_R1 > mn_PCWRow1, ;
  565.       ln_Win_R1 -1, mn_PCWRow1)
  566.    ln_Win_R2 = IIF(ln_Win_R2 < mn_PCWRow2, ;
  567.       ln_Win_R2 +1, mn_PCWRow2)
  568.    ln_Win_C1 = IIF(ln_Win_C1 > mn_PCWCol1, ;
  569.       ln_Win_C1 -1, mn_PCWCol1)
  570.    ln_Win_C2 = IIF(ln_Win_C2 < mn_PCWCol2, ;
  571.       ln_Win_C2 +1, mn_PCWCol2)
  572.    RELEASE WINDOW PopCalc7
  573.    IF ml_Shadow
  574.       IF ml_Move
  575.          DEACTIVATE WINDOW ShadCalc
  576.          DEFINE WINDOW ShadCalc ;
  577.          FROM ln_Win_R1+1,ln_Win_C1+2 ;
  578.          TO ln_Win_R2+1,ln_Win_C2+2 ;
  579.          color w/n,w/n,n/n panel
  580.          ACTIVATE WINDOW ShadCalc
  581.       ELSE
  582.          ACTIVATE SCREEN
  583.          @ ln_Win_R1+1, ln_Win_C1+2 ;
  584.          fill to ln_Win_R2+1,ln_Win_C2+2 ;
  585.          COLOR w/n
  586.       ENDIF
  587.    ENDIF
  588.    DEFINE WIND PopCalc7 ;
  589.    FROM ln_Win_R1, ln_Win_C1 ;
  590.    TO ln_Win_R2, ln_Win_C2 ;
  591.    DOUB color w+/rg,rg/rg,w+/rg
  592.    ACTIVATE WINDOW PopCalc7
  593.    IF ln_Win_R1=mn_PCWRow1 ;
  594.       .AND. ln_Win_R2=mn_PCWRow2 ;
  595.       .AND. ln_Win_C1=mn_PCWCol1 ;
  596.       .AND. ln_Win_C2=mn_PCWCol2
  597.       ** Maximum window size has been reached!
  598.       EXIT
  599.    ENDIF
  600. ENDDO
  601. RETURN
  602.  
  603. PROCEDURE Expshado
  604. PARAMETERS ln_Win_R1, ln_Win_C1, ln_Win_R2, ln_Win_C2
  605. ** Exploding Shadow - Top right to bottom left.
  606. ln_Shad_R2 = ln_Win_R1 +1
  607. ln_Shad_C2   = ln_Win_C1 + 2
  608. ACTIVATE SCREEN
  609. DO WHILE .t.
  610.    ln_Shad_R2 = IIF(ln_Shad_R2<ln_Win_R2 + 1,;
  611.    ln_Shad_R2+1,ln_Win_R2 + 1)
  612.    ln_Shad_C2 = IIF(ln_Shad_C2<ln_Win_C2 + 2,;
  613.    ln_Shad_C2+1, ln_Win_C2)
  614.    @ ln_Win_R1 + 1,ln_Win_C1 + 2 ;
  615.    FILL TO ln_Shad_R2,ln_Shad_C2 ;
  616.    color W/N
  617.    IF ln_Shad_R2=ln_Win_R2 + 1 ;
  618.       .AND. ln_Shad_C2=ln_Win_C2 + 2
  619.       EXIT
  620.    ENDIF
  621. ENDDO
  622. RETURN
  623.  
  624. PROCEDURE TapeDisp
  625. **    Provide a tape display.
  626. **    Save current screen and activate tape window.
  627. DO PC_OPEN2
  628. **    "Paint" the tape window.
  629. @ 0,2 SAY "PopCalc7 Tape" color R/W
  630. @ 1,0 TO 1,17 COLOR n/w
  631. @ 12,0 TO 12,17 COLOR n/w
  632. @ 13,1 SAY " P = Print Tape" color n/w
  633. @ 14,1 SAY " C = Clear Tape" color n/w
  634. @ 15,1 SAY " <Esc> to exit!" color n/w
  635. ** Initialize display specific memvars.
  636. mn_TapeCnt = mn_TapeNum
  637. mn_TapeEnd = mn_TapeNum
  638. mn_TapeNum=1
  639. ln_TapeTop=0
  640. IF mn_TapeCnt>10
  641.    mn_TapeNum=mn_TapeCnt-9
  642. ENDIF
  643. DO WHIL .T.
  644.    ln_TapeLin=2
  645.    IF ln_TapeTop # mn_TapeNum
  646.       **    Display only if required.
  647.       ln_TapeTop = mn_TapeNum
  648.       **    If there are numbers "above" currently
  649.       **    displayed tape, indicate so, otherwise,
  650.       **    redraw the line where "More" displays.
  651.       IF mn_TapeNum > 1 .AND. mn_TapeEnd>9
  652.          @ 1,10 SAY " More" + CHR(24) + " " ;
  653.          color RG+/W
  654.       ELSE
  655.          @ 1,10 TO 1,17 color n/w
  656.       ENDIF
  657.       **    "List" the tape array in the window.
  658.       DO WHIL mn_TapeNum <= mn_TapeEnd
  659.          @ ln_TapeLin,1 say ma_Tape[mn_TapeNum,1] ;
  660.          color n/w
  661.          @ ln_TapeLin,3 say ma_Tape[mn_TapeNum,2] ;
  662.          pict "#########.####"  color n/w
  663.          ln_TapeLin=ln_TapeLin+1
  664.          mn_TapeNum=mn_TapeNum+1
  665.       ENDDO
  666.       **    If there are numbers "below" currently
  667.       **    displayed tape, indicate so, otherwise,
  668.       **    redraw the line where "More" displays.
  669.       IF mn_TapeNum<mn_TapeCnt+1
  670.          @ 12,10 SAY " More"+CHR(25)+" ";
  671.          color RG+/W
  672.       ELSE
  673.          @ 12,10 TO 12,17 color n/w
  674.       ENDIF
  675.    ENDIF
  676.    ln_InKey=inkey(0)
  677.    DO CASE
  678.       CASE ln_Inkey = 28
  679.          **    F1 - HELP
  680.          DO CalcHelp with 6
  681.          LOOP
  682.       CASE CHR(ln_InKey)$"Cc"
  683.          DO TapeInit
  684.          EXIT
  685.       CASE CHR(ln_InKey)$"Pp"
  686.          **    Print the tape.
  687.          DO TapePrnt
  688.       CASE ln_InKey=27 .OR. ln_InKey = 13
  689.          EXIT
  690.       CASE ln_InKey=5
  691.          **    UpArrrow - Move tape UP one.
  692.          mn_TapeNum=ln_TapeTop-1
  693.       CASE ln_InKey=24
  694.          **    DownArrow - Move the tape DOWN one.
  695.          mn_TapeNum=ln_TapeTop+1
  696.       CASE ln_InKey=18
  697.          **    PgUp  - Page up the tape.
  698.          mn_TapeNum=ln_TapeTop-10
  699.       CASE ln_InKey=3
  700.          **    PgDn - Page down the tape.
  701.          mn_TapeNum=ln_TapeTop+10
  702.       CASE ln_InKey=26
  703.          **    HOME
  704.          **    Position the tape at the logical top.
  705.          mn_TapeNum=1
  706.       CASE ln_InKey=2
  707.          **    END
  708.          **    Position the tape at logical bottom.
  709.          mn_TapeNum=mn_TapeCnt-9
  710.       CASE ln_InKey < 32 .AND. ml_Move
  711.          DO Move_Win with ln_InKey, mn_PTWRow1, ;
  712.          mn_PTWRow2, mn_PTWCol1, mn_PTWCol2
  713.          LOOP
  714.       OTHERWISE
  715.          **    Safeguard: should not get to here.
  716.          LOOP
  717.    ENDCASE
  718.    IF mn_TapeCnt<=10
  719.       mn_TapeNum=1
  720.    ENDIF
  721.    IF mn_TapeNum < 1
  722.       **    mn_TapeNum cannot be less than 1.
  723.       mn_TapeNum = 1
  724.    ENDIF
  725.    IF mn_TapeNum > mn_TapeCnt
  726.       **    Check for logical end of tape.
  727.       mn_TapeNum = ln_TapeTop
  728.    ENDIF
  729.    IF (mn_TapeNum+9) < mn_TapeCnt
  730.       mn_TapeEnd = mn_TapeNum+9
  731.    ELSE
  732.       mn_TapeNum = ;
  733.       IIF(mn_TapeCnt-9>0,mn_TapeCnt-9,1)
  734.       mn_TapeEnd = mn_TapeCnt
  735.    ENDIF
  736. ENDDO
  737. mn_TapeNum = mn_TapeCnt
  738. **    Get rid of tape window - restore the screen.
  739. DO PC_Clos2
  740. RETURN
  741.  
  742. PROCEDURE TapePrnt
  743. IF .NOT. printstatus()
  744.    ?? chr(7)+chr(7)+chr(7)
  745.    RETURN
  746. ENDIF
  747. SET CONS OFF
  748. SET PRINT ON
  749. ? "PopCalc7 Tape Listing" AT 5
  750. ? "---------------------" AT 5
  751. ln_TapeLin=1
  752. DO WHIL ln_TapeLin<=mn_TapeCnt
  753.    ? ma_Tape[ln_TapeLin,1] AT 6,
  754.    ?? ma_Tape[ln_TapeLin,2] pict "#########.####" ;
  755.    AT 8
  756.    ln_TapeLin=ln_TapeLin+1
  757. ENDDO
  758. ? "---------------------" AT 5
  759. ? "     End of Tape     " AT 5
  760. SET PRINT OFF
  761. SET CONS ON
  762. EJECT
  763. RETURN
  764.  
  765. PROCEDURE PasteVal
  766. ** Assign a function key as a paste key.
  767. ** Open the secondary window.
  768. DO PC_OPEN2
  769. @ 0,2 SAY "PopCalc7 Paste" color b/w
  770. @ 1,0 TO 1,17 DOUB color n/w
  771. @ 2,0  SAY "      PRESS      "  color n/w
  772. @ 3,0  SAY "   Function Key  "  color n/w
  773. @ 4,0 to 4,17 doub color n/w
  774. @ 5,0  SAY "      Range"  color n/w
  775. @ 6,0  SAY "  From      Thru"  color n/w
  776. @ 7,0 TO 7,17 color n/w
  777. @ 8,0  say "   F2       F10"  color n/w
  778. @ 9,0  say "Shift-F1  Shift-F9"  color n/w
  779. @ 10,0 say " Ctrl-F1  Ctrl-F10"  color n/w
  780. @ 11,0 TO 11,17 doub color n/w
  781. @ 14,0 to 14,17  color n/w
  782. @ 15,0 SAY "  <Esc> to Abort!" color r/w
  783. ln_FuncKey=0
  784. ** Test for a valid key press.
  785. DO WHILE .t.
  786.    @ 3,16
  787.    ln_FuncKey=inkey(0)
  788.    DO CASE
  789.       CASE ln_FuncKey=27 .OR. ;
  790.          (ln_FuncKey < 0 .AND. ln_FuncKey> -29)
  791.          EXIT 
  792.       CASE ln_FuncKey = 28
  793.          ** F1 - HELP
  794.          DO CalcHelp with 5
  795.       CASE ln_FuncKey < 32 .AND. ml_Move
  796.          DO Move_Win with ln_Funckey, mn_PTWRow1, ;
  797.          mn_PTWRow2, mn_PTWCol1, mn_PTWCol2
  798.       OTHERWISE
  799.          ?? chr(7)+chr(7)
  800.          @ 12,0 say "   INVALID KEY!" color r*/w
  801.          @ 13,0 say "     Re-Enter " color rg+/w
  802.    ENDCASE
  803. ENDDO
  804. mn_FuncKey = -1 * ln_FuncKey + 1 + ;
  805. int((ln_FuncKey)/10)*10
  806. lc_FuncVal  = LTRIM(STR(mn_CalcAns,14,4))
  807. lc_FuncVal  = TrimZero(lc_FuncVal)
  808. DO CASE
  809.    CASE ln_FuncKey < 0 .AND. ln_FuncKey > -10
  810.       **     Function key was pressed.
  811.       SET FUNC mn_FuncKey TO lc_FuncVal
  812.    CASE ln_FuncKey < -9 .AND. ln_FuncKey > -20
  813.       **    Ctrl-Function key was pressed.
  814.       lc_funcstr = ;
  815.       ltrim(trim(str(mn_funckey,2,0)))
  816.       SET FUNCTION CTRL-F&lc_funcstr. ;
  817.          TO lc_FuncVal
  818.    CASE ln_FuncKey<-19 .AND. ln_FuncKey>-29
  819.       **    Shift-Function key was pressed
  820.       lc_funcstr = ;
  821.       ltrim(trim(str(mn_funckey,2,0)))
  822.       SET FUNCTION SHIFT-F&lc_funcstr. ;
  823.          TO lc_FuncVal
  824. ENDCASE
  825. ** Close the secondary window
  826. DO PC_Clos2
  827. RETURN
  828.  
  829. FUNCTION TrimZero
  830.    PARAMETER lc_TrimZer
  831.    **   Trim trailing zeros and decimal point.
  832.    DO WHILE RIGHT(lc_TrimZer,1)$"0"
  833.       ln_LenStr = LEN(lc_TrimZer) - 1
  834.       lc_TrimZer = LEFT(lc_TrimZer,ln_LenStr)
  835.    ENDDO
  836.    ln_LenStr = LEN(lc_TrimZer) - 1
  837.    lc_TrimZer = IIF(RIGHT(lc_TrimZer,1)=".",;
  838.       LEFT(lc_TrimZer,ln_LenStr),lc_TrimZer)
  839. RETURN (lc_TrimZer)
  840. **    EOF TrimZero()
  841.  
  842. PROCEDURE PC_Open2
  843. IF ml_Shadow
  844.    DO EXPSHADO WITH mn_PTWRow1 , mn_PTWCol1,;
  845.    mn_PTWRow2, mn_PTWCol2
  846.    IF ml_Move
  847.       DEFINE WINDOW ShadTape ;
  848.       FROM mn_PTWRow1 + 1, mn_PTWCol1 + 2 ;
  849.       TO mn_PTWRow2 + 1, mn_PTWCol2 + 2 ;
  850.       PANEL color w/n,w/n,n/w
  851.       ACTIVATE WINDOW ShadTape
  852.    ENDIF
  853. ENDIF
  854. DEFINE WINDOW POPTAPE FROM mn_PTWRow1,mn_PTWCol1 ;
  855.    TO mn_PTWRow2,mn_PTWCol2 DOUBLE color N/W,W/W,r/W
  856. ACTIVATE WINDOW POPTAPE
  857. RETURN
  858.  
  859. PROCEDURE PC_Clos2
  860. RELEASE WINDOW PopTape
  861. IF ll_Shadwin
  862.    RELEASE WINDOW ShadTape
  863. ENDIF
  864. RETURN
  865.  
  866. PROCEDURE Move_Win
  867. PARAMETERS ln_key, ln_WRow1, ln_WRow2, ln_WCol1,;
  868. ln_WCol2
  869. DO CASE
  870.    CASE ln_key = 19
  871.       **   Left Arrow, move the window left by 1.
  872.       ln_MoveRow = 0
  873.       ln_MoveCol = -1
  874.    CASE ln_key = 1 .OR. ln_key = 5
  875.       **    CTRL-LeftArrow / UP arrow.
  876.       ln_MoveRow = -1
  877.       ln_MoveCol = 0
  878.    CASE ln_key = 4
  879.       **    RightArrow, move the window right by 1.
  880.       ln_MoveRow = 0
  881.       ln_MoveCol = 1
  882.    CASE ln_key = 6 .OR. ln_Key = 24
  883.       **    CTRL-RightArrow /  DOWN arrow.
  884.       ln_MoveRow = 1
  885.       ln_MoveCol = 0
  886.    CASE ln_key = 9 .OR. ln_key = 2
  887.       **    Tab  /  End
  888.       ln_MoveRow = 0
  889.       ln_MoveCol = 79 - ln_WCol2 - ;
  890.       IIF(ml_Shadow,2,0)
  891.    CASE ln_key = -400 .OR. ln_key = 26
  892.       **    Shift Tab  /  Home
  893.       ln_MoveRow = 0
  894.       ln_MoveCol = -ln_WCol1
  895.    CASE ln_key = 18
  896.       **    PgUp - move to TOP Row
  897.       ln_MoveRow = -ln_WRow1
  898.       ln_MoveCol = 0
  899.    CASE ln_key=31
  900.       **    Ctrl-PageUp
  901.       **    Move window to top right of screen
  902.       ln_MoveRow = -ln_WRow1
  903.       ln_MoveCol = 79 - ln_WCol2 - ;
  904.       IIF(ml_Shadow,2,0)
  905.    CASE LASTKEY() = 3
  906.       **    PgDown - move to BOTTOM Row
  907.       ln_MoveRow = IIF(ll_PCStat,23,24) -ln_WRow2 -;
  908.       IIF(ml_Shadow,1,0)
  909.       ln_MoveCol = 0
  910.    CASE ln_key=30
  911.       **    Ctrl-PgDn
  912.       **    Move window to bottom right of screen
  913.       ln_MoveRow = IIF(ll_PCStat,23,24) - ln_WRow2-;
  914.       IIF(ml_Shadow,1,0)
  915.       ln_MoveCol = 79 -ln_WCol2 - IIF(ml_Shadow,2,0)
  916.    CASE ln_key = 29
  917.       **    Ctrl-Home - move to upper LEFT corner
  918.       ln_MoveRow = -ln_WRow1
  919.       ln_MoveCol = -ln_WCol1
  920.    CASE ln_key = 23
  921.       **    Ctrl-End - move to lower LEFT corner
  922.       ln_MoveRow = IIF(ll_PCStat,23,24) - ln_WRow2-;
  923.       IIF(ml_Shadow,1,0)
  924.       ln_MoveCol = -ln_WCol1
  925.    OTHERWISE
  926.       RETURN
  927. ENDCASE
  928. IF ln_WRow1 + ln_MoveRow < 0 ;
  929.    .OR. ln_WCol1 + ln_MoveCol < 0 .OR. ;
  930.    ln_WRow2 +ln_MoveRow > IIF(ll_PCStat,23,24) - ;
  931.    IIF(ml_Shadow,1,0) .OR. ;
  932.    ln_WCol2 + ln_MoveCol > IIF(ml_Shadow,77,79)
  933.    @ 0,0 SAY CHR(7) + CHR(7)
  934.    RETURN
  935. ENDIF
  936. ln_WRow1 = ln_WRow1 + ln_MoveRow
  937. ln_WCol1 = ln_WCol1 + ln_MoveCol
  938. ln_WRow2 = ln_WRow2 + ln_MoveRow
  939. ln_WCol2 = ln_WCol2 + ln_MoveCol
  940. DO CASE
  941.    CASE Window() = "POPCALC7"
  942.       IF ml_Shadow
  943.          MOVE WINDOW ShadCalc ;
  944.          BY ln_MoveRow,ln_MoveCol
  945.       ENDIF
  946.       MOVE WINDOW PopCalc7 BY ln_MoveRow,ln_MoveCol
  947.    CASE Window() = "POPTAPE"
  948.       IF ml_Shadow
  949.          MOVE WINDOW ShadTape ;
  950.          BY ln_MoveRow,ln_MoveCol
  951.       ENDIF
  952.       MOVE WINDOW PopTape BY ln_MoveRow,ln_MoveCol
  953. ENDCASE
  954. RETURN
  955.  
  956. PROCEDURE PC_Param
  957. PARAMETER ll_Test
  958. **    Enable restting of PopCalc7 parameters.
  959. **    (Tape_Size,Shadow,Move,Explode)
  960. ** NOTE: To get fancy, you might want to expand
  961. **       on this code to enable resetting the
  962. **       color settings.
  963. DECLARE la_Param[4]
  964. la_Param[1] = ml_Shadow
  965. la_Param[2] = ml_Explode
  966. la_Param[3] = ml_Move
  967. la_Param[4] = str(mn_TapeSiz,3,0)
  968. DEFINE WINDOW PC_PARAM from 4,23 to 13,52 ;
  969. DOUBLE color N/W,W+/N,R/W
  970. IF ml_shadow
  971.    DO EXPSHADO with 4, 23, 13, 52
  972. ENDIF
  973. ACTIVATE WINDOW PC_Param
  974. @ 0,4 say "Reconfigure PopCalc7" color n/w
  975. @ 1,0 to 1,27 color n/w
  976. @ 2,1 say "Shadows............. " + ;
  977. IIF(la_Param[1],"Yes","No ") color n/w
  978. @ 3,1 say "Exploding windows... " + ;
  979. IIF(la_Param[2],"Yes","No ") color n/w
  980. @ 4,1 say "Moving windows...... " + ;
  981. IIF(la_Param[3],"Yes","No ") color n/w
  982. @ 5,1 say "Tape size (20-580).. " + ;
  983. la_Param[4] color n/w
  984. @ 6,0 to 6,27 color n/w
  985. @ 7,3 say "Press Esc when done..." color r/w
  986. ln_x = 1
  987. ln_ParKey = 0
  988. DO WHILE .NOT. (ln_ParKey=23 .OR. ln_ParKey = 27)
  989.    IF ln_X<>4
  990.       @ ln_x+1,22 SAY ;
  991.       IIF(la_Param[ln_x],"Yes","No ") color w/n
  992.  
  993.       ln_ParKey = INKEY(0)
  994.       lc_ParKey = UPPER(CHR(ln_ParKey))
  995.       ** Allow for space bar toggle. CHR(32)
  996.       la_Param[ln_x] = iif(lc_ParKey=" ",;
  997.       (.NOT.la_Param[ln_x]),la_Param[ln_x])
  998.       la_Param[ln_x] = iif(lc_parKey$"YN",;
  999.       (lc_ParKey="Y"),la_Param[ln_x])
  1000.       @ ln_x+1,22 SAY ;
  1001.       IIF(la_Param[ln_x],"Yes","No ") color n/w
  1002.    ELSE
  1003.       lc_PassNum = la_Param[ln_x]
  1004.       DO ParamNum with lc_PassNum
  1005.       la_Param[ln_x] = lc_PassNum
  1006.       @ ln_x+1,22 SAY la_Param[ln_x] color N/w
  1007.    ENDIF
  1008.    DO CASE
  1009.       CASE ln_ParKey = 28
  1010.          ** F1 - HELP
  1011.          DO CalcHelp with 2
  1012.       CASE ln_ParKey = 5 .OR. ln_ParKey = 19  ;
  1013.          .OR. ln_ParKey = 1 .OR. ln_ParKey = -400
  1014.          **    UpArrow or LeftArrow
  1015.          **    Ctrl-LeftArrow or Shift Tab
  1016.          ln_x = ln_x - 1
  1017.       CASE ln_ParKey = 26 .OR. ln_ParKey = 18 .OR. ;
  1018.          ln_ParKey = 29 .OR. ln_ParKey = 31
  1019.          **    Home or PgUp or Ctrl-Home or Ctrl-PgUp
  1020.          ln_x = 1
  1021.       CASE ln_ParKey = 2 .OR. ln_ParKey = 3 .OR. ;
  1022.          ln_ParKey = 30
  1023.          **    End or PgDn or Ctrl-PgDn
  1024.          ln_x = 4
  1025.       CASE ln_ParKey = 4 .OR. ln_ParKey = 24 .OR. ;
  1026.          ln_ParKey = 13 .OR. ln_ParKey = 6 .OR. ;
  1027.          ln_ParKey = 9
  1028.          **    DownArrow/RightArrow/Enter
  1029.          **    Ctrl-RightArrow/Tab
  1030.          ln_x = ln_x + 1
  1031.    ENDCASE
  1032.    ln_x = IIF(ln_x>4,1,IIF(ln_x<1,4,ln_x))
  1033. ENDDO
  1034. ll_test = (la_Param[1] # ml_Shadow)
  1035. ll_test = IIF(ll_Test,.t.,;
  1036.    (la_Param[2] # ml_Explode))
  1037. ll_test = IIF(ll_Test,.t.,;
  1038.    (la_Param[3] # ml_Move))
  1039. ll_test = IIF(ll_Test,.t.,;
  1040.    (VAL(la_Param[4]) # mn_TapeSiz))
  1041. lc_Choice = iif(ln_ParKey=23 .AND. ;
  1042.    ll_test,"Y",iif(ll_test,"M","N"))
  1043. IF lc_Choice="M"
  1044.    ** Maybe...
  1045.    ?? CHR(7)
  1046.    @ 7,3 say " Keep changes (Y/N)   " COLOR R/W
  1047.    lc_Choice = UPPER(CHR(INKEY(0)))
  1048. ENDIF
  1049. IF lc_choice="Y" 
  1050.    IF VAL(la_Param[4]) <> mn_TapeSize
  1051.       @ 7,3 say " Initializing tape...  "
  1052.       mn_TapeSiz = VAL(la_Param[4])
  1053.       DECLARE ma_Tape[mn_TapeSiz,2]
  1054.       DO TapeInit
  1055.    ENDIF
  1056.    ml_Shadow  = la_Param[1]
  1057.    ml_explode = la_Param[2]
  1058.    ml_move    = la_Param[3]
  1059. ELSE
  1060.    ll_Test = .f.
  1061. ENDIF
  1062. RELEASE WINDOW PC_PARAM
  1063. RETURN
  1064.  
  1065. PROCEDURE ParamNum
  1066. PARAMETER lc_ParNum
  1067. @ 7,3 say "(+) (-) (Enter=Accept)" color r/w
  1068. DO WHILE .t.
  1069.    @ 5,22 SAY lc_ParNum color W/N
  1070.    ln_ParKey = inkey(0)
  1071.    lc_PKeyStr = UPPER(CHR(ln_ParKey))
  1072.    DO CASE
  1073.       CASE ln_ParKey = 27
  1074.          **    Escape has been pressed.
  1075.          **    Reset tape size to old size
  1076.          **    and exit.
  1077.          lc_ParNum = str(mn_TapeSiz,3,0)
  1078.          @ 5,22 SAY lc_ParNum color W/N
  1079.          EXIT
  1080.       CASE ln_ParKey = 28
  1081.          ** F1 - HELP
  1082.          DO CalcHelp WITH 2
  1083.       CASE ln_ParKey <32
  1084.          **    Enter or any other "navigation"
  1085.          **    key has been pressed.
  1086.          EXIT
  1087.       CASE lc_PKeyStr = "+"
  1088.          **    Upper array limit = 585
  1089.          **    But, to keep to clean, limit to 580
  1090.          IF lc_ParNum<="570"
  1091.             lc_ParNum = str(val(lc_parnum)+10,3,0)
  1092.          ELSE
  1093.             ?? chr(7)
  1094.          ENDIF
  1095.       CASE lc_PKeyStr = "-"
  1096.          **    Prevent tape from being to small.
  1097.          **    Too much time wasted in continually
  1098.          **    re-initializing a very small tape.
  1099.          IF lc_ParNum>=" 30"
  1100.             lc_ParNum = str(val(lc_parnum)-10,3,0)
  1101.          ELSE
  1102.             ?? chr(7)
  1103.          ENDIF
  1104.    ENDCASE
  1105. ENDDO
  1106. ** Prevent escaping from PROCEDURE PC_Param loop.
  1107. ln_ParKey = iif(ln_ParKey=27,4,ln_ParKey)
  1108. @ 7,3 say "Press Esc when done..." color r/w
  1109. RETURN
  1110.  
  1111. PROCEDURE CalcHelp
  1112. PARAMETER ln_HelpScr
  1113. ** Simple help text...
  1114. SAVE SCREEN TO CalcHelp
  1115. ACTIVATE SCREEN
  1116. IF ml_shadow
  1117.    DEFINE WINDOW ShadHelp FROM 2,6 TO 23,76 ;
  1118.    color w/n,w/n,n/w panel
  1119.    ACTIVATE WINDOW ShadHelp
  1120. ENDIF
  1121. DEFINE WINDOW CalcHelp from 1,4 to 22,74 color N/bg,,W+/bg
  1122. ACTIVATE WINDOW CalcHelp
  1123. DO WHILE ln_HelpScr <=6
  1124.    CLEAR
  1125.    DO CASE
  1126.       CASE ln_HelpScr = 1
  1127.          TEXT
  1128.  Operations                                            PopCalc7 Help
  1129. ═════════════════════════════════════════════════════════════════════
  1130.                Welcome to PopCalc7's HELP Facility            
  1131. ═════════════════════════════════════════════════════════════════════
  1132.  
  1133.  PopCalc7 operates much the same as most other calculators.
  1134.  
  1135.  You can add, subtract, multiply, divide, and exponentiate 
  1136.  both with "keyed" entries and values held in "memory".
  1137.  
  1138.  To Exit PopCalc7, or any associated windows, press <Esc>.
  1139.  
  1140.  You also have the ability to view and print the current "tape", 
  1141.  assign a value to a "paste" key, perform an immediate paste,  
  1142.  move the windows,  and you may re-configure PopCalc7's display 
  1143.  characteristics and tape size.
  1144.  
  1145.  To EXIT this help system at any point, press <Esc>.
  1146.  
  1147.                               More....                        Page 1
  1148.          ENDTEXT
  1149.       CASE ln_HelpScr = 2
  1150.          TEXT
  1151.  Configuration                                         PopCalc7 Help
  1152. ═════════════════════════════════════════════════════════════════════
  1153.  
  1154.  You may "re-configure" PopCalc7 by pressing "R" from within in the
  1155.  main calculator.  You may enable/disable the following:
  1156.  
  1157.                Shadows for all windows.   (YES/no)
  1158.                Exploding windows.         (YES/no)
  1159.                Moving windows.            (YES/no)
  1160.  
  1161.            <Press "Y", "N" , or the space bar to toggle>
  1162.  
  1163.  You may change the "Tape size" within the range 20 to 580.  
  1164.  CAUTION: Changing the tape size will reset the current tape.
  1165.  
  1166.  To change the tape size, press:   +  Increases.
  1167.                                    -  Decreases.
  1168.  
  1169.  
  1170.                               More....                        Page 2
  1171.          ENDTEXT
  1172.       CASE ln_HelpScr = 3
  1173.          TEXT
  1174.  Configuration (continued)                             PopCalc7 Help
  1175. ═════════════════════════════════════════════════════════════════════
  1176.  
  1177.  If both "moving windows" and "shadowing" are enabled, shadows
  1178.  will be opaque. Otherwise, transparent shadowing is in effect. 
  1179.  
  1180.  "Exploding windows" effects only the main calculator window.
  1181.  
  1182.  When "shadowing" is enabled, all shadowing will be of an 
  1183.  "explosive" variety.
  1184.  
  1185.  With "exploding windows" and "shadowing", the calculator shadow
  1186.  and window explode from the center.  If "shadowing" and not 
  1187.  "exploding", the shadow will explode from upper left to lower  
  1188.  right for the calculator window.
  1189.  
  1190.  All shadowing for other windows is exploded from upper left to 
  1191.  lower right.
  1192.  
  1193.                               More....                        Page 3
  1194.          ENDTEXT
  1195.       CASE ln_HelpScr = 4
  1196.          TEXT
  1197.         Key Press   Calc & Paste   Tape Window    Tape Display
  1198.       ────────────   ───────────   ───────────   ───────────────
  1199.          UpArrow         Up            n/a         Up One Line
  1200.          DnArrow        Down           n/a        Down One Line
  1201.       Ctrl-RtArrow       Up            Up              n/a
  1202.       Ctrl-LtArrow      Down          Down             n/a
  1203.          LtArrow        Left          Left             n/a
  1204.          RtArrow        Right         Right            n/a
  1205.            Tab        Far Right     Far Right          n/a
  1206.            End        Far Right        n/a         End of Tape
  1207.          Shift-Tab    Far Left      Far Left           n/a
  1208.            Home       Far Left         n/a         Top of Tape
  1209.            PgUp          Top           n/a        Back 10 Lines
  1210.            PgDn         Bottom         n/a        Down 10 Lines
  1211.         Ctrl-PgUp     Upper Right   Upper Right        n/a
  1212.         Ctrl-PgDn     Lower Right   Lower Right        n/a
  1213.         Ctrl-Home     Upper Left    Upper Left         n/a
  1214.         Ctrl-End      Lower Left    Lower Left         n/a
  1215.       ────────────   ───────────   ───────────   ───────────────
  1216.                               More....                        Page 4
  1217.          ENDTEXT
  1218.       CASE ln_HelpScr = 5
  1219.           ** NOTE TO PROGRAMERS: 
  1220.           **   You should adjust this help screen to
  1221.           **   reflect keys applicable to your code.
  1222.          TEXT
  1223.  PASTE KEYS                                            PopCalc7 Help
  1224. ═════════════════════════════════════════════════════════════════════
  1225.  
  1226.  Press "P" while in the main calculator to enable the paste function.
  1227.  
  1228.  A paste key will allow you to use place the calculated answer 
  1229.  into a data entry field.  A window will appear and prompt you
  1230.  to press a key which is to be used as the paste key:   
  1231.  
  1232.                         F2  thru  F10  
  1233.                   Shift-F1  thru  Shift-F9
  1234.                    Ctrl-F1  thru  Ctrl-F10
  1235.  
  1236.  Once you have returned to your application, a press of the paste
  1237.  key will then enter the stored number into your data entry field.
  1238.  
  1239.  NOTE: Pressing "I" from within calculator screen will immediately 
  1240.        exit PopCalc7 and paste the answer to the current field.
  1241.  
  1242.                               More....                        Page 5
  1243.          ENDTEXT
  1244.       CASE ln_HelpScr = 6
  1245.          TEXT
  1246.  TAPE                                                  PopCalc7 Help
  1247. ═════════════════════════════════════════════════════════════════════
  1248.  
  1249.  Pressing "T" in the main calculator window will open a "tape" of
  1250.  your calculator activity.
  1251.  
  1252.  The last entries will be shown initially.  If there are more than 
  1253.  ten (10) entries, "More" will be indicated on the top line. You 
  1254.  may scroll through the tape by pressing the appropriate keys as
  1255.  detailed proviously in this help session.
  1256.  
  1257.  While in the tape window:
  1258.  
  1259.     Press "P" to print the tape to an attached printer.
  1260.  
  1261.     Press "C" to clear the tape.
  1262.  
  1263.     Press "Esc" to return to the calculator window.
  1264.  
  1265.                             -*- END -*-                       Page 6
  1266.          ENDTEXT
  1267.    ENDCASE 
  1268.    ln_HelpKey = INKEY(0)
  1269.    DO CASE
  1270.       CASE ln_HelpKey = 5 .OR. ln_HelpKey = 19  ;
  1271.          .OR. ln_HelpKey = 18 .OR. ln_HelpKey =1;
  1272.          .OR. ln_HelpKey = -400
  1273.          **    UpArrow or LeftArrow or PgUp 
  1274.          **    Ctrl-LeftArrow or Shift Tab
  1275.          ln_HelpScr = ln_HelpScr - 1
  1276.       CASE ln_HelpKey = 26 .OR. ;
  1277.          ln_HelpKey = 29 .OR. ln_HelpKey = 31
  1278.          **    Home or Ctrl-Home or Ctrl-PgUp
  1279.          ln_HelpScr = 1
  1280.       CASE ln_HelpKey = 2 .OR. ln_HelpKey = 30 
  1281.          **    End or Ctrl-PgDn
  1282.          ln_HelpScr = 6
  1283.       CASE ln_HelpKey = 27 .OR. ln_HelpKey = 23
  1284.          ** Escape or Ctrl-End
  1285.          EXIT
  1286.       OTHERWISE
  1287.          ln_HelpScr = ln_HelpScr + 1
  1288.    ENDCASE
  1289.    IF ln_HelpScr>6 .or. ln_HelpScr<1
  1290.       ?? CHR(7)
  1291.    ENDIF
  1292.    ln_HelpScr = IIF(ln_HelpScr>6,6,iif(ln_HelpScr<1,1,ln_HelpScr))
  1293. ENDDO
  1294. RELEASE WINDOW CalcHelp
  1295. IF ml_shadow
  1296.    RELEASE WINDOW ShadHelp
  1297. ENDIF
  1298. RESTORE SCREEN FROM CalcHelp
  1299. RELEASE SCREEN CalcHelp
  1300. RETURN
  1301.  
  1302.