Re: Arrays

From: <wheath_at_comcast.net>
Date: Sat, 09 Jun 2007 15:59:30 +0000

Tony
yes, with the array useage you no longer need the cases - what I sent does run
ARRAY's are something I've been using since 1979
they are the simplest form of create does> words
I don't remember where I saw the definition first..
Swiftforth has an array in Tools/Optional packages/generic options/bigmath.f
: Carray ( MXI NAME -- )
    create 1+ /allot
    does> ( i a0 - a )
          + ;

: WARRAY ( MXI NAME -- )
   CREATE 1+ 2* /ALLOT
   DOES> ( I A0 - A )
         SWAP 2* + ; IMMEDIATE

\ to define an array
\ maxindex ARRAY nameofarray
\ to use an array
\ index nameofarray leaves address of that array cell on stack
\ #TABWINS ARRAY HTAB \ defines an array named htab with #tabwins cells
\ 0 HTAB @ \ leaves the contents of the first htab cell on the stack
\ 55 0 HTAB ! \ stores 55 into the first cell of the htab array

\ the 1+ adds an extra cell so I don't have to worry about
\ being off by 1 if my max index is 0 based or 1 based
: ARRAY ( MXI NAME -- )
   CREATE ( MXI ) \ compile time behavior
             1+ cells /ALLOT \ /allot erases the memory used at compile time
   DOES> ( I A0 - A ) \ execution time behavior A0 is automatic from does> action
         SWAP cells + ; IMMEDIATE

\ try these
: T1 ( - ) #tabwins 0 do i i htab ! loop ;
: T2 ( - ) #tabwins 0 do i htab @ . loop ;
0 htab #tabwins cells dump

Warren
-------------- Original message --------------
From: "Tony Senerchia" <asenerchia_at_gmail.com>

> Hi !
> Sorry that I took so long to respond, but I have been very busy as of late.
> First of all, thank you two for your advice! Things are starting to work a
> little more smoothly, though I still have some kinks to work out.
>
> Warren, I've been trying to modify what you sent so that it will do the job,
> but SwiftForth is complaining about "ARRAY" :
>
>
> #TABWINS ARRAY HTAB ( ALL TABBED WINDOW HANDLES )
>
>
> Is that from an optional package, something you created yourself or
> something I neglected to load? Otherwise, with what you sent me, am I
> correct in assuming that I no longer need the cases because the program will
> automatically hide the window stored in HSHOW and show the newly selected
> window?
>
>

----------------------------------------------------------------------
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 Sat Jun 09 2007 - 08:59:52 PDT


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.