• SAVE-SYSTEM scripting and compilation to an executable

    From none) (albert@21:1/5 to All on Sat Sep 30 14:37:22 2023
    As is well known you can run scripts by lina/wina/ciforth

    This is a script:

    ------------ 8< ----- hello.sh ------------------
    #!./lina -s
    "hello world" CR
    ------------ 8< -----------------------
    chmod +x hello.sh
    `` hello.sh '' invokes this script.

    ------------ 8< ----- withfp.sh --------------
    #!./lina -s
    WANT -fpwa- SAVE-SYSTEM
    "lina+fp" SAVE-SYSTEM
    ------------ 8< ------------------------------
    chmod +x withfp.sh

    This generates a `` lina+fp '' with all the floating point facilities available. We use -fpwa- instead of -fp-. The assembler that is needed
    is loaded in a temporary buffer and discarded before the SAVE-SYSTEM.

    lina+fp is a full blown Forth that interprets all options:

    ------------ 8< ----- sqrt.sh --------------
    #!./lina+fp -s
    1 ARG[] EVALUATE FSQRT FS. CR
    ------------ 8< ----- sqrt.sh --------------
    chmod +x sqrt.sh

    ~/PROJECT/ciforths: sqrt.sh 2.0E0
    SCRIPT-NAME : ISN'T UNIQUE
    BY-WHO : ISN'T UNIQUE
    MY-ERROR : ISN'T UNIQUE
    1.414213562373095048E0

    You see that the script-facility is loaded again.
    If the UNIQUE message bothers you, you can add:

    ------------ 8< ----- withfp.sh --------------
    #!./lina -s
    WANT -fpwa- SAVE-SYSTEM
    'SCRIPT-NAME HIDDEN
    'BY-WHO HIDDEN
    'MY-ERROR HIDDEN
    "lina+fp" SAVE-SYSTEM
    ------------ 8< ------------------------------
    chmod +x withfp.sh

    The -c option generates elf executables as usual:
    ------------ 8< --- sqrt.frt -----------------
    : main 1 ARG[] EVALUATE FSQRT FS. CR ;
    ------------ 8< ------------------------------

    ~/PROJECT/ciforths: lina+fp -c sqrt.frt
    ~/PROJECT/ciforths: sqrt 2.0E
    1.414213562373095048E0

    You probably don't trade your favorite forth for ciforth, but
    maybe you feel inspired.

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)