Re: Newbie text input question



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 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 ;

Hi Doug,
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
.



Relevant Pages

  • Re: Newbie text input question
    ... I am working on a program that sends control signals to the serial port ... to send morse code from text entered at the keyboard. ...
    (comp.lang.forth)
  • Newbie text input question
    ... I am working on a program that sends control signals to the serial port to ... send morse code from text entered at the keyboard. ...
    (comp.lang.forth)
  • Re: Newbie text input question
    ... I am working on a program that sends control signals to the serial port to ... send morse code from text entered at the keyboard. ...
    (comp.lang.forth)
  • Re: Newbie text input question
    ... 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 morse trainer isn't exactly what you want but it may give you some ideas. ...
    (comp.lang.forth)
  • Re: Open Question on SPARC Server 670MP
    ... >graphics card out of my SPARC Station 20 into it, and attached a keyboard. ... it also helps to connect a serial terminal to serial port ... If the power-on self-tests run to completion, the system board in the ... If both give settings of 'ttya' then you need to change the ...
    (comp.sys.sun.hardware)