home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
tutor
/
l5p160
< prev
next >
Wrap
Text File
|
1990-07-15
|
6KB
|
100 lines
\ ╔════════════════════════════════════════════════════╗
\ ║ Lesson 5 Part 160 F-PC 3.5 Tutorial by Jack Brown ║
\ ╚════════════════════════════════════════════════════╝
\
\ JB#EDIT part 1 of 4: capture the next four messages and make
\
\ your copy of JB#EDIT.SEQ or download JB#LEDIT.ZIP from BCFB
\ File: JB#EDIT.SEQ
\ Original Date: September 12, 1988
\ Last Modified: April 20, 1990
\ Author: Jack W. Brown
\ Function: Single, Double, and Floating Variable editing
\ and numeric input.
\ Note: Floating point operators assume VP-Planner floating
\ point routines are loaded. VPSFP101.ZIP or later.
CR .( Requires VP-Planner Floating point to be loaded. )
\ ┌────────────────────────────────────────────────────────────────────┐
\ │ Description │
\ ├────────────────────────────────────────────────────────────────────┤
\ │ One characteristic ( perhaps novel ) of these operators is │
\ │ that they take the address of a variable ( single, double or │
\ │ floating ) and allow the user to edit the contents of the │
\ │ variable. │
\ │ │
\ │ VARIABLE A 123 A ! followed by: │
\ │ A S#ED would display 123 on the screen │
\ │ in a default field 6 spaces wide. │
\ │ │
\ │ User could then edit or modify the number and upon pressing │
\ │ return the changed value would be automatically stored back │
\ │ in the VARIABLE A │
\ │ │
\ │ 2VARIABLE B 123.45 B 2! followed by: │
\ │ B D#ED would do the same for doubles in │
\ │ a default field 12 wide. │
\ │ │
\ │ FVARIABLE C 1.56E-4 C F! followed by: │
\ │ C F#ED would do the same for floating │
\ │ point with 12 the default field. │
\ │ │
\ │ A similar family of words, WS#ED , WD#ED , and WF#ED │
\ │ allowed the user to specify his own field width, and yet │
\ │ another family of words, XYWS#ED , XYWD#ED , and XYWF#ED │
\ │ allow users to specify the column X , row Y , and the width W. │
\ │ │
\ │ Here is the whole family: adr = variable address, x is cursor │
\ │ column, y is cursor row, and w is input field width. │
\ │ │
\ │ S#ED ( adr -- ) WS#ED ( adr w -- ) XYWS#ED ( adr x y w -- ) │
\ │ D#ED ( adr -- ) WD#ED ( adr w -- ) XYWD#ED ( adr x y w -- ) │
\ │ F#ED ( adr -- ) WF#ED ( adr w -- ) XYWF#ED ( adr x y w -- ) │
\ │ │
\ │ Using the above operators it is a simple mater to implement │
\ │ a more traditional set of operators that leave their input on │
\ │ on the parameter or floating point stack. │
\ │ │
\ │ S#IN ( -- n ) WS#IN ( w -- n ) │
\ │ XYWS#IN ( x y w -- n ) │
\ │ D#IN ( -- dn) WD#IN ( w -- dn) │
\ │ XYWD#IN ( x y w -- dn) │
\ │ │
\ │ Floating point input operators left values on the floatinng │
\ │ point stack. │
\ │ parameter stack floating point stack │
\ │ F#IN ( P: -- ) ( F: -- r ) │
\ │ WF#IN ( P: w -- ) ( F: -- r ) │
\ │ XYWF#IN ( P: x y w -- ) ( F: -- r ) │
\ └────────────────────────────────────────────────────────────────────┘
ONLY FORTH ALSO DEFINITIONS
CREATE TPAD 34 ALLOT TPAD 34 BLANK
CREATE SNUM 10 ALLOT \ Scratch variable of ????IN operators.
\ Leave a true flag if string begins with a -ve sign.
\ Note we assume a counted string!! adr is 1 less than the
\ the first string character.
: ANY-SIGN? ( adr -- adr' flag )
DUP 1+ C@ DUP ASCII - = \ Increment adr , check for -
IF DROP 1+ TRUE \ Leave true flag if found.
ELSE ASCII + = \ Allow a +sign if desired.
IF 1+ THEN \ Increment past + sign
FALSE \ and leave false flag.
THEN ;
\ Move up to first non blank of string. Actually adr' points
\ to position before first non blank!!
: SKIP-BLANKS ( adr -- adr' )
BEGIN 1+ DUP C@ BL <> UNTIL 1- ;
\ Set cursor from 16 bit hi-x lo-y format.
: CUR! ( xy -- ) SPLIT AT ;
\ Fetch cursor to 16 bit form.
: CUR@ ( -- xy ) IBM-AT? FLIP + ;