Difference: MicroSdBlocks (83 vs. 84)

Revision 842021-06-21 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
%DASHBOARD{ section="banner"
Line: 298 to 298
 

File Redirection

There are many Forth words to format a string e.g. emit, type or print something to the console. It is also possible to fetch user input like key, accept, etc. All these words can be used on files. Nothing new for a UNIX user. Mecrisp use hooks for redirection terminal IO, these hooks can also be used for file redirection.
Added:
>
>

Step by Step Redirection to a File

 Sample to use hook-emit for redirection output from ls -l to a file.

Open file test.tmp

Line: 351 to 352
 hook-emit ! ok.
Added:
>
>

Redirection the Easy Way

create fil /FIL allot
256 buffer: path
path .str" test.tmp"
path fil f_open drop
>file ls -l
>term
>f_close drop

 Some helper words in redirection.fs
: >f_open ( addr c-addr -- ior )  \ open a file to redirect to (emit, type, ...)
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback