Cameron,
An solution is to push successive adresses on the stack and finally
construct an array from the stack-data.
Regards,
Charles
\ ----- CODE -----
: FLD+ ( n*x n -- m*y m ) \ where m=n+1
HERE SWAP 1+ ;
: STACK>ARRAY ( n*x n -- )
CREATE DUP 0 ?DO DUP i - ROLL , LOOP DROP
DOES> ( n addr -- addr )
SWAP CELLS ( DIM * ) + @ ;
\ ----------- TEST -------------
0 \ precede declarations with zero !
FLD+ ,Z" my"
FLD+ ,Z" taylor"
FLD+ ,Z" is"
FLD+ ,Z" rich"
STACK>ARRAY BLOC-DATA[]
: TEST ( -- )
4 0 DO I BLOC-DATA[] ZCOUNT CR TYPE LOOP ;
TEST
----------
> De : SF Talk <sftalk_at_forth.com>
> A : SF Talk <sftalk_at_forth.com>
> Objet : Structures with string data
> Date : jeudi 28 octobre 1999 23:54
>
> Date: Wed, 27 Oct 1999 18:52:55 -0400
> From: Cameron Bowes <cbowes_at_worldnet.att.net>
> Subject: Structures with string data
>
> Greetings -
>
> I'm working through Petzold's Programming Windows95 to get myself up to
speed
> with the WIn32 API. Several programs in the book use a structure defined
as
> (for example in Chapter 3):
>
> struct
> {
> int iIndex;
> char *szLabel;
> char *szDesc;
> }
>
> then defines an array:
>
> sysmetrics [] =
> {
> SM_CXSCREEN, "SM_CXSCREEN", "Screen width in pixels",
> SM_CYSCREEN, "SM_CYSCREEN", "Screen height in pixels",
> ...
> }
>
> using the structure.
>
> I'm stumped at setting up a similar definition in Swiftforth. I found
> Options\Win32\MsgText.f which uses a neat [SWITCH keyword, DATA: which
lets you
> comma-quote variable length string data into the switch structure, but
that's
> not quite generalized enough since access is through the switch value,
not a
> simple index. BTW, is DATA: described anywhere? I couldn't find
reference to
> it in the docs.
>
> Am I missing something simple where I should be using CREATE...DOES?
>
> Any tips would be greatly appreciated!
>
> Kindest regards,
>
> Cam Bowes
> cbowes_at_worldnet.att.net
>
>
>
.
Received on Fri Oct 29 1999 - 14:57:26 PDT
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 09-Feb-2012. Archive updated nightly.