• Toad User abort with cut: ... -cut

    From sjack@21:1/5 to All on Thu Oct 17 15:55:17 2024
    Toad doesn't have CATCH/THROW but FigForth provides user abort (ABORT) .
    Have BacForth type words in RTC vocabulary. Using BACK...TREK and
    CUT: ... -CUT made SNAPSHOT error handler to show stacks and return
    to cleanup code marked by CUT: . Not nearly as capable and slick as
    CATCH/THROW but adequate for my light-weight applications.

    Have CATCH/THROW in Frog but Toad is all about making full use of
    FigForth facilities (use of abundant vocabularies has been very
    entertaining, ain't KISS.)

    User abort with cut: ... -cut



    Some code

    -- SNAPSHOT
    -- User abort action
    -- dump data stack and top of return stack
    -- (return stack top holds the address of the word where the
    -- fault was detected. )
    -- Process each cut: cleanup location
    : SNAPSHOT
    RTC
    BEGIN
    -CUT
    cr ." --- (!) User abort: "
    cr ." Data stack: " s? xx
    cr ." Return : " r .
    cr ." --."
    cr
    LDEPTH 0= UNTIL
    cr ;

    -- YO
    -- Display some items of interest
    : YO
    rtc
    cr ." L-stack depth: " ldepth .
    cr ." LP : " lp@ . tab lp@ @ .
    +voc
    cr ." (ABORT) : " ' (ABORT) @ CELL+ NFA ID.
    cr ." UABORT : " dfa' uabort @ CELL+ NFA ID.
    cr ." FDIID : " fdiid . \ file id, zero after cleanup
    cr
    ;


    Success example

    "pad/txt" svdir sv! \ assign input path prefix
    ' snapshot is uabort \ assign user abort
    -uabort \ enable user abort
    -pause \ allow pausing
    fviews -p rubyatXLIX rubyatLI; \ view two files with pause option

    pad/txt/rubyatLI:

    LI.
    The Moving Finger writes; and, having writ,
    Moves on: nor all thy Piety nor Wit
    Shall lure it back to cancel half a Line,
    Nor all thy Tears wash out a Word of it.

    -more-

    pad/txt/rubyatXLIX:

    XLIX.
    Tis all a Chequer-board of Nights and Days,
    Where Destiny with Men for Pieces plays:
    Hither and thither moves, and mates, and slays,
    And one by one back in the Closet lays.
    +uabort \ disable user abort
    yo \ look at items of interest
    L-stack depth: 0
    LP : 134566380 -1
    (ABORT) : ABORT
    UABORT : SNAPSHOT
    FDIID : 0

    ..CURRENT and CONTEXT are WRK BASE: 10 Latest: YO


    Fail example

    -uabort
    fviews rubyatXLIX foo rubyatLI; \ foo doesn't exit, should fail

    pad/txt/rubyatLI:

    LI.
    The Moving Finger writes; and, having writ,
    Moves on: nor all thy Piety nor Wit
    Shall lure it back to cancel half a Line,
    Nor all thy Tears wash out a Word of it.


    pad/txt/foo:

    --- (!) User abort:
    Data stack: 134583709 10 134582004 -2 666
    Return : 134581372
    --.

    --- (!) User abort:
    Data stack: empty
    Return : 134582140
    --.

    --- (!) FVIEWS abandon
    +uabort
    yo
    L-stack depth: 0
    LP : 134566380 -1
    (ABORT) : ABORT
    UABORT : SNAPSHOT
    FDIID : 0

    ..CURRENT and CONTEXT are WRK BASE: 10 Latest: YO


    -fin-
    OK

    --
    me

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