Check input device is a terminal: Difference between revisions

Added Forth entry.
mNo edit summary
imported>CyD
(Added Forth entry.)
Line 172:
C:\test < in.txt
Input doesn't come from tty.</pre>
 
 
=={{header|Forth}}==
{{works with|gforth|0.7.3}}
In Gforth, the word "source-id" is used to determine the program source.
 
If you got a program file "source.f":
<syntaxhighlight lang="Forth">
: ?tty source-id if ." not " then ." from terminal" ; ?tty bye
</syntaxhighlight>
Then,
<syntaxhighlight lang="bash">gforth source.f</syntaxhighlight> in the shell will display:
{{out}}<pre>not from terminal</pre>
Then,
<syntaxhighlight lang="bash">gforth -e ': ?tty source-id if ." not " then ." from terminal" ; ?tty bye'</syntaxhighlight> will display:
{{out}}<pre>not from terminal</pre>
 
At Gforth prompt,
<syntaxhighlight lang="bash">: ?tty source-id if ." not " then ." from terminal" ; ?tty bye</syntaxhighlight> will display:
{{out}}<pre>from terminal</pre>
 
 
=={{header|FutureBasic}}==
Anonymous user