This is G o o g l e's cache of http://home.earthlink.net/~neilbawd/detab.html.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:XfpSk9GNBmUC:home.earthlink.net/~neilbawd/detab.html+&hl=en&ie=UTF-8


Google is not affiliated with the authors of this page nor responsible for its content.

DETAB

DETAB

TEXT

Wil Baden 2000-07-07

Requires Tool Belt, Slurp, and Output Redirection.

#TAB-SPACES         ( -- n )
The value used with #TAB-CHAR to align output.
.DETAB              ( str len -- )
Display a string with #TAB-CHAR expanded for a multiple of #TAB-SPACES.
DETAB               ( "filename" -- )
Replace the lines of filename with #TAB-CHAR expanded for a multiple of #TAB-SPACES.
Program Text 1
 
ONLY FORTH DEFINITIONS  ALSO OUTPUT-REDIRECTION

\ 09 CONSTANT #TAB-CHAR

4 VALUE #TAB-SPACES

   VARIABLE COLUMN

: .DETAB            ( str len -- )
    0 COLUMN !
    BEGIN  DUP WHILE
        2DUP  #TAB-CHAR SCAN  /SPLIT
            DUP COLUMN +!  TYPE
    DUP WHILE
        #TAB-SPACES  COLUMN @  OVER MOD -
            DUP COLUMN +!  SPACES
        1 /STRING
    REPEAT THEN
    2DROP ;

: DETAB             ( "filename" -- )
    SPONGE >OUTPUT                       ( src length)
        BEGIN  DUP 0> WHILE
            SPLIT-NEXT-LINE              ( . . str len)
            TRIM .DETAB CR               ( src' length')
        REPEAT 2DROP                     ( )
        'OUTPUT @ CLOSE-FILE FILE-CHECK
    0 >OUTPUT ;

ONLY FORTH DEFINITIONS


Go back to Neil Bawd's home page.