[SWITCH ... RUN-SUPER

From: ForthCAD <mail_at_forthcad.com>
Date: Mon, 29 Mar 1999 13:07:21 +0100

{ ==========
The problem is to execute the previous method for the same message in a [+SWITCH.

I suspect there exist a possibility to start the search-process from the previous list-node entry.

My solution here is to redef [+SWITCH as a [SWITCH. But its not very nice.

A better method will be interesting.

Charles Melice
======== }

0 VALUE (PREV-SWITCH-XT)

: [+SWITCH
>IN @ >R
    ' DUP TO (PREV-SWITCH-XT) \ save previous switch
    R@ >IN ! :SWITCH \ redef switch with previous as default
    R> >IN ! [+SWITCH ; \ execute [+switch

: RUN-SUPER ( n -- ) (PREV-SWITCH-XT) COMPILE, ; IMMEDIATE

\ --------------------------------------
\ example
\ --------------------------------------

: FOODEFAULT . ." not used" ;

[SWITCH FOO FOODEFAULT
    1 RUN: ." ONE" ;
    2 RUN: ." TWO" ;
    3 RUN: ." THREE" ;
SWITCH]

[+SWITCH FOO
    1 RUN: ." UN" ;
    2 RUN: ." DEUX" ;
    3 RUN: 3 RUN-SUPER ." , say TROIX in french" ; \ use previous method
SWITCH]

\ EOF

.
Received on Mon Mar 29 1999 - 13:07:21 PST


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 08-Feb-2012. Archive updated nightly.