Edit this page

asciibox.fs

This code prints a box made of asterisks of the specified height and width

: star 42 emit ;
: top 0 do star loop cr ; : bottom top ;
: middle star 2 - 0 do space loop star cr ;
: box ( width height -- ) cr over top 2 - 0 do dup middle loop bottom ;

|
| RetroForth version of asciibox.fs
|
: star '* emit ;
: top : bottom repeat star until cr ;
: middle star 2 - repeat space until star cr ;
: box ( width height -- ) cr over top 2 - for dup middle next bottom ;

See Also

Forth Code

Forth

Edit this page · home ·