home *** CD-ROM | disk | FTP | other *** search
- *******************
-
- PROCEDURE Pop_calc
-
- PARAMETERS p, l, v
-
- IF EMPTY(PCOUNT())
- p = ""
- l = ""
- v = ""
- ENDIF
-
- IF TYPE("_invals") = "U"
- PUBLIC _invals, _lastval, _lastop, _thisval, _thisop, _isnegative
- PUBLIC _mode, _total, _qwert
- IF MEMORY(0) >= 12
- PUBLIC _ticker[50]
- AFILL(_ticker, "")
- ENDIF
- STORE "" TO _invals
- STORE 0 TO _lastval, _lastop, _thisval, _thisop
- STORE .F. to _isnegative
- STORE 1 TO _mode
- IF !EMPTY(v)
- _total = &v.
- ELSE
- _total = ""
- ENDIF
- ENDIF
-
- IF TYPE("scrcursor") = "U"
- scrcursor = .T.
- ENDIF
-
- PRIVATE _poprow, _popcol, _curcol, _temp, _ocolor, _jb, _putitback
-
- _temp = ""
- _putitback = ""
- _chandle = FOPEN("\CALC.POS", 2)
- IF _chandle > 0 && the file exists
- _ccct = SPACE(4)
- _ctemp = FREAD(_chandle, @_ccct, 4)
- _poprow= VAL(SUBSTR(_ccct, 1, 2))
- _popcol= VAL(SUBSTR(_ccct, 3))
- FCLOSE(_chandle)
- ELSE
- _poprow = 1
- _popcol = IF(COL() <= 35, 45, 1)
- ENDIF
-
- IF TYPE("scrcursor") = "U"
- scrcursor = .T.
- ENDIF
-
- SET KEY ASC("=") TO _Force13
-
- _calcol = SETCOLOR()
- SET CURSOR OFF
- DO WHILE .T.
- BEGIN SEQUENCE
- Windowpush(_poprow,_popcol,_poprow+15, _popcol + 28,"","","","","","",.T.)
- _jb = .F.
- _ocolor = SETCOLOR()
- POPCALC1() && This is the display
- _one13 = .F.
- KEYBOARD "+"
- POPIT()
- EXIT
- END
- Windowpop()
- ENDDO
- Windowpop()
- SET KEY ASC("=") TO
- SETCOLOR(_calcol)
- SET CURSOR (scrcursor)
-
- *******************
-
- PROCEDURE _Force13
-
- KEYBOARD CHR(13)
-
- *******************
-
- PROCEDURE Popit
-
- DO WHILE .T.
- _oldkey = LASTKEY()
- _keypress = INKEY(0)
- IF _keypress = 27
- IF !EMPTY(_putitback)
- KEYBOARD _putitback + CHR(1)
- ENDIF
- EXIT
- ELSEIF _keypress = 28
- Windowpush(WROW(1),WCOL(2),WROW(1)+12,WCOL(2)+23,"","","","","","",.T.)
- Wsayget( 1,2,"INS - Dragging")
- Wsayget( 2,2,"ENTER once for =")
- Wsayget( 3,2," twice to store")
- Wsayget( 4,2,"ESC - To Exit")
- Wsayget( 6,2,"This does not support")
- Wsayget( 7,2," HEX math.")
- Wsayget( 9,2," T - Show Tape")
- Wsayget(11,2,"<<any key to return>>")
- INKEY(0)
- Windowpop()
-
- ELSEIF _keypress = 22
- POPCALDRAG()
- ELSEIF _keypress = 13
- IF _one13
- IF TYPE(v) = "N"
- _putitback = STRVALUE(_total)
- ELSEIF TYPE(v) = "C"
- _putitback = STRVALUE(_total)
- ENDIF
- * EXIT
- ELSE
- _one13 = .T.
- KEYBOARD "="
- ENDIF
- ELSEIF _keypress = 19 .OR. _keypress = 8
- _invals = SUBSTR(_invals, 1, LEN(_invals)-1)
- WSAYGET( 2, 4, FILL_OUT(_invals, 20))
-
- ELSEIF CHR(_keypress)$"+=-/*"
- IF CHR(_keypress) = "-"
- IF CHR(_oldkey)$"0123456789."
- POPCALC2()
- ELSE
- POPCALC3()
- is_negative = .T.
- ENDIF
- ELSE
- POPCALC2()
- ENDIF
- IF MEMORY(0) >= 12
- IF !EMPTY(_lastval)
- AINS(_ticker, 1)
- _ticker[1] = TRANSFORM(_qwert, "99999999.99") + " " + CHR(_keypress)
- IF CHR(_keypress) = "="
- AINS(_ticker, 1)
- _ticker[1] = TRANSFORM(_lastval, "99999999.99") + " TOTAL"
- ENDIF
- ENDIF
- ENDIF
-
- ELSEIF CHR(_keypress)$"Cc"
- WSAYGET( 2, 4, SPACE(20))
- STORE "" TO _invals, _putitback
- STORE 0 TO _lastval, _lastop, _thisval, _thisop, _total
- IF !EMPTY(v)
- _total = &v.
- ENDIF
- STORE .F. to _isnegative
- KEYBOARD "+"
- _one13 = .F.
- IF MEMORY(0) >= 12
- AINS(_ticker, 1)
- _ticker[1] = "CLEARED"
- ENDIF
- _ttcol = SETCOLOR()
- SETCOLOR(_ocolor)
- WSAYGET(03,18, SPACE(6))
- SETCOLOR(_ttcol)
-
- ELSEIF CHR(_keypress)$"Tt"
- IF MEMORY(0) >= 12
- POPTICK()
- POPCALC1()
- ENDIF
-
- ELSEIF CHR(_keypress)$"Ee"
- _one13 = .F.
- WSAYGET( 2, 4, SPACE(20))
- STORE "" TO _invals
-
- ELSEIF CHR(_keypress)$"1234567890."
- _one13 = .F.
- POPCALC3()
-
- ELSEIF CHR(_keypress)$"DHdh"
- POPCALC4()
-
- ELSEIF (_keypress <= -4 .AND. _keypress >= -9) .AND. _mode != 1
- _one13 = .F.
- * IF _lastval = 3
- IF LEN(_invals) # 20
- _invals = _invals + SUBSTR("ABCDEF", ABS(_keypress+3), 1)
- WSAYGET( 2, 4, FILL_OUT(_invals, 20))
- ENDIF
- * ENDIF
-
- ENDIF
- ENDDO
-
- *******************
-
- PROCEDURE Poptick
-
- _start = 1
- _tend = WDEPTH()
- _oldcol = SET_COLOR(ATTRIBUTE(_poprow+1, _popcol+1))
- _tickwait = .T.
- Windowpush(_poprow,_popcol,_poprow+15, _popcol + 28,"BLUE","WHITE","","","","",.T.)
- SETCOLOR(SET_COLOR(ATTRIBUTE(24,00)))
- DO WHILE _tickwait
- _panning = 1
- CLEAR_AREA()
- FOR _x = _start TO _start + 11
- IF _x <= LEN(_ticker)
- WSAYGET(_panning, 2, TRANSFORM(_x, "99. ") + _ticker[_x])
- _panning = _panning + 1
- ENDIF
- NEXT
- WSAYGET(14, 2, "Esc to Quit")
- DO WHILE .T.
- _tdummy = INKEY(0)
- IF _tdummy = 27
- _tickwait = .F.
- EXIT
- ELSEIF _tdummy = 28
- Windowpush(WROW(1),WCOL(2),WROW(1)+12,WCOL(2)+23,"","","","","","",.T.)
- WSAYGET( 1,2,"There are up to the")
- WSAYGET( 2,2,"last 50 transactions")
- WSAYGET( 3,2,"on the tape. The")
- WSAYGET( 4,2,"transactions are in")
- WSAYGET( 5,2,"reverse order.")
- WSAYGET( 6,2,"ESC, PgUp, PgDn are")
- WSAYGET( 7,2,"valid keys.")
- WSAYGET( 9,2,"Press Any key to")
- WSAYGET(10,2,"continue.....")
- INKEY(0)
- Windowpop()
-
- ELSEIF _tdummy = 3
- IF !(LEN(_ticker) < (_start + 11))
- _start = _start + 11
- ENDIF
- EXIT
-
- ELSEIF _tdummy = 18
- IF (_start - 12) > 0
- _start = _start - 11
- ENDIF
- EXIT
-
- ENDIF
- ENDDO
- ENDDO
- Windowpop()
- SETCOLOR(_oldcol)
-
- *******************
-
- PROCEDURE Popcaldrag
-
- t_row = WROW()
- t_col = WCOL()
- b_row = WROW() + 15
- b_col = WCOL() + 28
- _tttscr = PUSHSCREEN()
- _tts1 = VAL(SUBSTR(allwindows[_tttscr], 1, 2))
- _tts2 = VAL(SUBSTR(allwindows[_tttscr], 4, 2))
- _tts3 = VAL(SUBSTR(allwindows[_tttscr], 7, 2))
- _tts4 = VAL(SUBSTR(allwindows[_tttscr], 10,2))
- DO WHILE .T.
- RESTSCREEN(_tts1, _tts2, _tts3, _tts4, allscreens[_tttscr])
- @ t_row,t_col,b_row,b_col BOX REPLICATE(CHR(177), 8)
- @ t_row,t_col SAY ""
- _whatkey = INKEY(0)
- DO CASE
- CASE _whatkey = 27
- EXIT
- CASE _whatkey = 5
- IF t_row - 1 > - 1
- t_row = t_row - 1
- b_row = b_row - 1
- ENDIF
- CASE _whatkey = 24
- IF b_row + 1 < 25
- t_row = t_row + 1
- b_row = b_row + 1
- ENDIF
- CASE _whatkey = 19
- IF t_col - 1 > 1
- t_col = t_col - 1
- b_col = b_col - 1
- ENDIF
- CASE _whatkey = 4
- IF b_col + 1 < 79
- b_col = b_col + 1
- t_col = t_col + 1
- ENDIF
- CASE _whatkey = 13
- _poprow = t_row
- _popcol = t_col
- _chandle = FCREATE("\CALC.POS")
- FWRITE(_chandle, TRANSFORM(_poprow, "99")+TRANSFORM(_popcol, "99"), 4)
- FCLOSE(_chandle)
- EXIT
- ENDCASE
- ENDDO
- POPSCREEN()
- BREAK
-
- *******************
-
- PROCEDURE Popcalc1
-
- SETCOLOR(IF((ISCOLOR() .AND. !(IF(TYPE("scrmono")="U", .T., scrmono))), "W/B", SETCOLOR()))
- WSAYGET(00, 0, "╔═══════════════════════════╗")
- WSAYGET(01, 0, "║ ╔═══════════════════════╗ ║")
- WSAYGET(02, 0, "║ ║ 0.0000 ║ ║")
- WSAYGET(03, 0, "║ ║ Dec ║ ║")
- WSAYGET(04, 0, "║ ╚═══════════════════════╝ ║")
- WSAYGET(05, 0, "║─ Hex ─┬─Modes─┬─ Numeric ─║")
- WSAYGET(06, 0, "║ │ │ = 7 8 9 - ║")
- WSAYGET(07, 0, "║ A B │ Dec │ ║")
- WSAYGET(08, 0, "║ F5 F6 │ │ / 4 5 6 ║")
- WSAYGET(09, 0, "║ C D │ Hex │ ║")
- WSAYGET(10, 0, "║ F7 F8 │ │ * 1 2 3 + ║")
- WSAYGET(11, 0, "║ E F │ Tpe │ ║")
- WSAYGET(12, 0, "║ F9 F10│ │ 0 . ║")
- WSAYGET(13, 0, "║───────┴───────┼───────────║")
- WSAYGET(14, 0, "║ CALCIT │ C CE ║")
- WSAYGET(15, 0, "╚═══════════════════════════╝")
-
- IF MEMORY(0) < 12
- WSAYGET(11,12, " ")
- ENDIF
-
-
- SETCOLOR(IF((ISCOLOR() .AND. !(IF(TYPE("scrmono")="U", .T., scrmono))), "W/Y", "W+/N"))
-
- WSAYGET( 6,18, "=")
- WSAYGET( 6,26, "-")
-
- WSAYGET( 8, 2, "F5")
- WSAYGET( 8, 5, "F6")
-
- WSAYGET( 8,18, "/")
-
- WSAYGET(10, 2, "F7")
- WSAYGET(10, 5, "F8")
- WSAYGET(10,18, "*")
- WSAYGET(10,26, "+")
-
- WSAYGET(7,11, "D")
- WSAYGET(9,11, "H")
-
- IF MEMORY(0) >= 12
- WSAYGET(11,11, "T")
- ENDIF
-
- WSAYGET(12, 2, "F9")
- WSAYGET(12, 5, "F10")
-
- WSAYGET(14,19, "C")
- WSAYGET(14,23, "E")
- WSAYGET(14,26, "")
- WSAYGET( 3, 4, IF(_mode = 1, "Dec", "Hex"))
-
- SETCOLOR(IF((ISCOLOR() .AND. !(IF(TYPE("scrmono")="U", .T., scrmono))), "W/RB", REVERSE(SETCOLOR())))
-
- WSAYGET( 2, 4, SPACE(20))
-
- *******************
-
- PROCEDURE Popcalc2
-
- IF TYPE("_isnegative") = "U"
- _isnegative = .F.
- ENDIF
- _thisval = IF(_isnegative, -1 * VAL(_invals), VAL(_invals))
- IF CHR(_keypress)="+"
- _ttcol = SETCOLOR()
- SETCOLOR(_ocolor)
- WSAYGET(03,18, "Add ")
- SETCOLOR(_ttcol)
- _thisop = 1
- ELSEIF CHR(_keypress)="-"
- _ttcol = SETCOLOR()
- SETCOLOR(_ocolor)
- WSAYGET(03,18, "Minus ")
- SETCOLOR(_ttcol)
- _thisop = 2
- ELSEIF CHR(_keypress)="/"
- _ttcol = SETCOLOR()
- SETCOLOR(_ocolor)
- WSAYGET(03,18, "Divide")
- SETCOLOR(_ttcol)
- _thisop = 3
- ELSEIF CHR(_keypress)="*"
- _ttcol = SETCOLOR()
- SETCOLOR(_ocolor)
- WSAYGET(03,18, "Multi.")
- SETCOLOR(_ttcol)
- _thisop = 4
- ENDIF
- _LASTFUNC()
-
- IF CHR(_keypress)="="
- _ttcol = SETCOLOR()
- SETCOLOR(_ocolor)
- WSAYGET(03,18, "Equals")
- SETCOLOR(_ttcol)
- _total = _lastval
- WSAYGET( 2, 4, FILL_OUT(LTRIM(TRIM(STR(_lastval))), 20))
- STORE "" TO _invals
- * STORE 0 TO _lastval, _lastop, _thisval, _thisop
- * STORE .F. to _isnegative
- * KEYBOARD "+"
- ELSE
- STORE "" TO _invals
- _jb = .T.
- ENDIF
-
- *******************
-
- PROCEDURE _Lastfunc
-
- IF !EMPTY(_lastop) .AND. !EMPTY(_thisval)
- DO CASE
- CASE _lastop = 1
- _temp = _lastval + _thisval
- CASE _lastop = 2
- _temp = _lastval - _thisval
- CASE _lastop = 3
- _temp = _lastval / _thisval
- CASE _lastop = 4
- _temp = _lastval * _thisval
- ENDCASE
- _qwert = _thisval
- _lastval = _temp
- _thisval = 0
- * perform last operation on _lastval and _thisval,
- * move results to _lastval, clear _thisval, and move _thisop
- * to _lastop
- ELSEIF !EMPTY(_lastop)
- _lastval = _thisval
- ENDIF
- _lastop = _thisop
- _thisop = 0
-
- *******************
-
- PROCEDURE Popcalc3
-
- IF _mode = 1 .OR. _mode = 3
- IF _mode = 3 .AND. CHR(_keypress) = "."
- RETURN
- ENDIF
- IF _jb
- _jb = .F.
- WSAYGET( 2, 4, SPACE(20))
- ENDIF
- IF LEN(_invals) # 20
- _invals = _invals + CHR(_keypress)
- WSAYGET( 2, 4, FILL_OUT(_invals, 20))
- ENDIF
- ENDIF
-
- *******************
-
- PROCEDURE Popcalc4
-
- IF CHR(_keypress)$"Dd"
- _amode = 1
- ELSEIF CHR(_keypress)$"Hh"
- _amode = 3
- ENDIF
-
- IF _mode = 1 && Decimal mode
- IF _amode = 3
- _invals = DECIHEXI( _invals )
- _invals = IF(_invals = "0", "", _invals)
- ENDIF
- ELSE && Hex mode
- IF _amode = 1
- _invals = HEXIDECI(_invals)
- ENDIF
- ENDIF
- _mode = _amode
- _memocolor = SETCOLOR()
- SETCOLOR(IF((ISCOLOR() .AND. !(IF(TYPE("scrmono")="U", .T., scrmono))), "W/Y", REVERSE(SETCOLOR())))
-
- WSAYGET( 3, 4, IF(_mode = 1, "Dec", IF(_mode = 2, "Bin", "Hex")))
-
- SETCOLOR(_memocolor)
- _invals = IF(TYPE("_invals")="N", IF(EMPTY(_invals), "", LTRIM(STR(_invals))), _invals)
- WSAYGET( 2, 4, FILL_OUT(_invals, 20))
-
- * End of File
-