Re: Newbie text input question
- From: Coos Haak <chforth@xxxxxxxxx>
- Date: Mon, 27 Oct 2008 23:48:13 +0100
Op Mon, 27 Oct 2008 17:28:48 -0600 schreef Bob Liesenfeld:
"Doug Hoffman" <dhoffman@xxxxxxxxxxxxxxx> wrote in message
news:f2ed0$49050dfa$c4b2e71$9713@xxxxxxxxxxxxxxxx
Bob Liesenfeld wrote:Hi Doug,
Hi gang,
I am working on a program that sends control signals to the serial port
to send morse code from text entered at the keyboard. This is an
exercise to learn more about Forth as well as to use it on the air. As a
first cut attempt I have re-defined the letters a-z to words that in turn
send the appropriate 'on-off' signals to the RTS pin on the com1 serial
port with the correct (and modifiable timings). However, I realize the
re-defining characters is not the way to go. What I >really< what is to
have the program read input from the keyboard, and call the words that
output the correct signals. Through my reading, I --think-- some
incantation of EXPECT is what I want but I can't seem to get my brain
around how to do it.
An array of executable tokens should work. The offset into the zero-based
array is the char value minus 97 ( ascii a) times the cell width.
-Doug
: action0 ." actiona" ;
: action1 ." actionb" ;
: action2 ." actionc" ;
: action3 ." actiond" ;
\ etc
create action \ the array of XTs
' action0 ,
' action1 ,
' action2 ,
' action3 ,
\ etc
\ assumes all lower case input
: input
pad 1 expect pad c@ 97 - ( 0 thru 25 )
cells ( offset) action + @ execute ;
Ok.....I'm stuggling to get my mind around your code. I think I'm
getting there.....I have been working through it line by line on my system
using F-PC. (Yes, I know it is ancient, but I like it's help system :) )
F-PC does not seem to have a 'cells' word, but from some research I have
done, it would appear to return the size of a word (8, 16, 32 bits) on the
system in use. Is this correct?
Thanks again for the help.
Bob
You could define for F-PC
: cells 2* ;
: cell+ 2+ ;
A much up to date choice however would be Win32Forth, assuming you use a
Windows machine.
Or Gforth if you like working at a DOS prompt.
--
Coos
CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html
.
- References:
- Newbie text input question
- From: Bob Liesenfeld
- Re: Newbie text input question
- From: Doug Hoffman
- Re: Newbie text input question
- From: Bob Liesenfeld
- Newbie text input question
- Prev by Date: Re: Newbie text input question
- Next by Date: Re: Newbie text input question
- Previous by thread: Re: Newbie text input question
- Next by thread: Re: Newbie text input question
- Index(es):
Relevant Pages
|