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

Re: Improvements

From: Gene LeFave <gene_at_tekdata.com>
Date: Mon, 05 May 2003 13:39:26 -0500

You could use a different case statement.

Gene

CR .( Wil Baden CASE STATEMENT)
: PREVIOUS> LAST @ NAME> >CODE ;
-? : CASE POSTPONE BEGIN PREVIOUS> +BAL ; IMMEDIATE
-? : OF POSTPONE OVER POSTPONE =
      POSTPONE IF POSTPONE DROP ; IMMEDIATE

: ENDIFS ( a1 a2 ... --) BEGIN DEPTH 0= IF EXIT THEN
      DUP PREVIOUS> > WHILE S" THEN" EVALUATE REPEAT
      DUP PREVIOUS> = IF 2DROP -BAL -BAL THEN ; IMMEDIATE
-? : ENDCASE ( a1 a2 ... --) ( n-)
      POSTPONE DROP POSTPONE ENDIFS ; IMMEDIATE
-? : ENDOF POSTPONE ELSE ; IMMEDIATE

\ : TRY ( n) CASE 1 OF 1 . ENDOF .S 2 OF 2 . ENDOF
\ 1 2+ OF 3 . ENDOF DUP . ." No Match..." ENDCASE CR ;
\ : TRI ( n) CASE DUP 1 = IF . ELSE DUP 2 = IF . ELSE
\ 1 2+ OF 3 . ENDOF DUP . ." No Match..." ENDCASE CR ;

On 29 Apr 2003 at 12:53, Glenn Dixon wrote:

Date sent: Tue, 29 Apr 2003 12:53:24 -0600
From: "Glenn Dixon" <dixong_at_networld.com>
To: sftalk_at_forth.com
Subject: [sftalk] Re: Improvements
Send reply to: sftalk_at_forth.com

> rvn>Inside a definition, use a CASE OF ENDOF ENDCASE
> statement to achieve this.
>
> I'm sorry, I use CASE all the time but must be dumb. How does one use
> it to test for multiple ANDed and ORed conditions instead of testing a
> single number on the stack? Would it be something like
>
> Case drop
> n1 n2 = n3 n4 = and IF ...action... ENDOF
> .
> .
> endcase
> ?
>
> I've never seen anything like this done.
>
> Thanks,
> Glenn
>
>
>
>
>
>
> *********************************
> Get your free E-Mail and Homepage
> Go to http://www.networld.com
> *********************************
>
> ----------------------------------------------------------------------
> 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
> ----------------------------------------------------------------------
>
>

----------------------------------------------------------------------
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 Mon May 05 2003 - 11:46:55 PDT

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