Re: Structures with string data

From: Dennis Ruffer <druffer_at_forth.com>
Date: Fri, 29 Oct 1999 08:26:42 -0700

Cam,

Sorry for not speaking up sooner, but I was curious what you all could come
up with. If you know where to look, you can find many concepts within the
actual source code. In this case, the ListView sample contains what is
needed:

CLASS HOUSEINFO
  18 BUFFER: szAddress
   9 BUFFER: szCity
    VARIABLE iPrice
    VARIABLE iBeds
    VARIABLE iBaths
END-CLASS

0 HOUSEINFO BUILDS[] rgHouseInfo[]
   ,Z" 100 Berry Lane " ,Z" Redmond " 175000 , 3 , 2 ,
   ,Z" 523 Apple Road " ,Z" Redmond " 125000 , 4 , 2 ,
   ,Z" 1212 Peach Street" ,Z" Redmond " 200000 , 4 , 3 ,
   ,Z" 22 Daffodil Lane " ,Z" Bellevue" 2500000 , 4 , 4 ,
   ,Z" 33542 Orchid Road" ,Z" Bellevue" 180000 , 3 , 2 ,
   ,Z" 64134 Lily Street" ,Z" Bellevue" 250000 , 4 , 3 ,
   ,Z" 33 Nicholas Lane " ,Z" Seattle " 350000 , 3 , 2 ,
   ,Z" 555 Tracy Road " ,Z" Seattle " 140000 , 3 , 2 ,
   ,Z" 446 Jean Street " ,Z" Seattle " 225000 , 4 , 3 ,
   0 ,

Note that the class instance is built with no data, and the data is added
after the header. You may not know ,Z" either. It lays down a null
terminated string.

The, the usage is very simple:

        5 rgHouseInfo[] iPrice @

BTW, Rick and I had to puzzle this out for a bit too! ;)

DaR

> 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 - 08:26:42 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.