gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get stdin that is passed to Gforth from command line in Debian fo


From: Philip Smith
Subject: How to get stdin that is passed to Gforth from command line in Debian for example?
Date: Tue, 25 Feb 2020 16:41:14 -0700

I need help with how to get the stdin from command line like the following:

 $  echo "hello world testing" | ./test.fs -e "(get-ext-stdin$)"

I want to receive the string "hello world testing" in this command line
echoed string to my gforth program called test.fs .   Currently the
following command line works with my test.f code:

$ echo "(get-ext-stdin$) hello world test" | ./test.fs

This works because the command (get-ext-stdin$) is a word in test.fs that
takes the source and changes >in to point to the end of the stdin string.
This i could still use but i want to be able to not have to put the command
in the string itself as in the first example.

Here is my current code that works with the above command line example
where the word (get-ext-stdin$) is in the string.

\  start of test.fs
#! /usr/local/bin/gforth

variable ext-stdin$

: otherwords
  ." this is other words working here!" cr ;

: (get-ext-stdin$)
  source ext-stdin$ $!
  ext-stdin$ $@ dump cr
  source swap drop >in !
  otherwords
  ." now for some more stuff " cr
  bye ;

:noname ; is bootmessage
\ end of test.fs

The output of this code using the first command line is as follows :

(get-ext-stdin$) hello world test
7FFFF6225778: 28 67 65 74  2D 65 78 74 - 2D 73 74 64  69 6E 24 29
 (get-ext-stdin$)
7FFFF6225788: 20 68 65 6C  6C 6F 20 77 - 6F 72 6C 64  20 74 65 73   hello
world tes
7FFFF6225798: 74                       -                           t

this is other words working here!
now for some more stuff


I understand that the stdin is being treated as the keyboard input in this
code and as such the strings could execute commands in gforth or cause an
error if they did not exist so some way to drop this input from being
interpreted would be a good idea but not totally needed since the main word
that i would use to start this code would always exit with bye.

Any solution or ideas would be appreciated!
-- 
                \|||/
-----0oo---( o o )---oo0------
                (_)
>From the hand of PKS


reply via email to

[Prev in Thread] Current Thread [Next in Thread]