programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

System to improve the LOCALS| legibility.

From: Charles Melice <mail_at_forthcad.com>
Date: Tue, 10 Jun 2003 15:31:05 +0200

optional LOCALVAL.F

\ -----------------------------------------------
\ Other system to improve the LOCALS| legibility.
\ -----------------------------------------------
\ Usage example:
\
\ : Test ( D E -- )
\ [LOCALS \ Begins locals definition.
\ : D \ : allocate+assign.
\ : E
\ 1 : A
\ 2 : B
\ 3 : C
\ LOCALS] \ Builds LOCALS|.
\ A B + C * D + E + . ;
\
\ -----------------------------------------------

vocabulary localval

also localval definitions

    256 constant (pad-size)
    (pad-size) chars buffer (pad)

previous definitions also localval

: [LOCALS ( -- )
    also localval
    s" |" (pad) place ; immediate

: INSERT ( from nfrom to -- )
    count locals| ntou tou nfrom from |
    \ right shift destination string
     tou
     tou nfrom chars +
     ntou chars
    move
    \ insert existing string
    from tou nfrom chars move
    \ update count char
    ntou nfrom + tou 1 chars - c! ;

definitions

: LOCALS] ( -- )
    previous
    s" locals|" (pad) insert
    \ cr (pad) count type cr
    (pad) count evaluate ; immediate

: : ( val "name" -- )
    bl word count
    \ check used size in local '(pad)'
    dup (pad) c@ + 11 + (pad-size) > abort" (pad) buffer full"
    \ concat value name
    (pad) insert
    s" " (pad) insert ; immediate

previous definitions

\\ Test

: Test ( D E -- )
    [locals
          : D
          : E
        1 : A
        2 : B
        3 : C
    locals]
    A B + C * D + E - . ;

10 20 Test \ -1 = (1+2)*3+10-20

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Tue Jun 10 2003 - 06:40:48 PDT

This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:32 PST