home *** CD-ROM | disk | FTP | other *** search
- \ ╔════════════════════════════════════════════════════╗
- \ ║ Lesson 5 Part 180 F-PC 3.5 Tutorial by Jack Brown ║
- \ ╚════════════════════════════════════════════════════╝
-
- \ JB#EDIT.SEQ Part 3 of 4
-
- \ ┌───────────────────────────────────────────────────────┐
- \ │ 16 bit Variable Editing and 16 bit Numeric Input. │
- \ └───────────────────────────────────────────────────────┘
-
- \ As above but field width is specified on the stack.
- : WS#ED ( adr w -- )
- >R
- TPAD 1+ 32 CHFL FILL \ blank input field.
- R@ TPAD C!
- DUP @ DUP 0= \ Is number 0 ?
- IF DROP \ if so provide blank field
- ELSE S>D TUCK DABS \ other wise
- <# #S ROT SIGN #> \ format number and move
- TPAD 1+ SWAP R@ \ to the edit buffer.
- MIN CMOVE
- THEN
- TPAD R> (#ED) DROP SWAP ! ;
-
- \ Edit single number a current cursor position using default
- \ field with of 6. Edit buffer is at TPAD
- : S#ED ( adr -- )
- 6 WS#ED ;
-
- \ As above but cursor & field width are specified on the stack.
- : XYWS#ED ( adr x y n -- )
- -ROT AT WS#ED ;
-
- \ Input single number with field width on stack
- \ and leave resulting single number on the parameter stack.
- : WS#IN ( w -- n )
- 0 SNUM ! SNUM SWAP WS#ED SNUM @ ;
-
- \ Input single number in a default field 6 wide
- \ and leave on parameter stack.
- : S#IN ( -- n )
- 6 WS#IN ;
-
- \ Input single number at cursor postion x y using a field width w
- \ and leave the resulting single number on the parameter stack.
- : XYWS#IN ( x y w -- n )
- 0 SNUM ! ROT SNUM SWAP 2SWAP XYWS#ED SNUM @ ;
-
- \ ┌────────────────────────────────────────────────────────────────────┐
- \ │ Floating point varialbe editing and floating point numeric input. │
- \ └────────────────────────────────────────────────────────────────────┘
-
- HEX
-
- \ This routine edits a counted string and converts it to a double number.
- \ cur is cursor x y packed into one word.
- : ED_FCONVERT ( adr n cur -- cur adr n dn )
- BEGIN DUP >R \ a n c Position cursor.
- -ROT R> SPLIT 2OVER \ c a n x y a n
- LINEEDITOR DROP \ c a n Edit string.
- OVER COUNT + BL SWAP C! \ FIX
- OVER SKIP-BLANKS \ c a n Move up to non-blank
- ANY-SIGN? \ c a n a' flg / sgn[dn]
- >R 0 0 ROT 8000 \ c a n |dn| a' -1
- BEGIN DPL ! FCONVERT \ c a n |dn| a"
- DUP C@ ASCII . = \ c a n |dn| a" flg
- WHILE 0 REPEAT \ c a n |dn| a" 0
- DUP C@ 0DF AND \ Allow lower case e for exponent.
- ASCII E = \ c a n |d| a3 f2 / sgn[dn]
- IF DPL @ 0 MAX >R \ c a n |d| a3 f2 / DPL sgn[dn]
- ANY-SIGN? >R \ c a n |d| a3 f2 / sgn[exp] DPL sgn[dn]
- DUP C@ \ c a n |dn| a5 c / sgn[exp] DPL sgn[dn]
- DUP CHFL =
- SWAP BL = OR
- IF R> R> 2DROP \ c a n |dn| a5 / sgn[D]
- ELSE DBL0 ROT
- FCONVERT \ c a n |dn| de a6 / sgn[de] DPL sgn[dn]
- NIP SWAP
- R> NOT
- ?NEGATE
- R> + DPL ! \ c a n |dn| a6 / sgn[dn]
- THEN
- THEN \ c a n |dn| a7 / sgn[dn]
- C@ DUP CHFL =
- SWAP BL = OR NOT \ c a n |dn| flag / sgn[dn]
- WHILE 2DROP R> DROP BEEP \ c a n
- ASCII ? 2 PICK 1+ C! ROT \ a n c Mark error
- REPEAT R> ?DNEGATE \ c a n dn
- DPL @ 8000 = IF DPL OFF THEN ; \ DPL=0 if .pt not entered
- DECIMAL
-
-