Re: Structures with string data

From: Haas, David <david.haas_at_owenscorning.com>
Date: Fri, 29 Oct 1999 08:56:17 -0400

Cameron, I have also been working through Petzold as a "background task" as
I have time.

This is how I initialized the system metrics structure. I put this in a
separate file
and included it in the various Petzold SYSMET* programs.

****************************************************************************
************
****************************************************************************
************

{ -------------------------------------------------------------------------
   Define and initialize the system metrics display structure array
   -------------------------------------------------------------------------
}

\ Number of array elements
68 VALUE NumLines

\ Define the structure
CLASS SYSMETRICS
      VARIABLE Index
   22 BUFFER: Label
   40 BUFFER: Desc
END-CLASS

\ Array of structures
NumLines SYSMETRICS BUILDS[] SysMetrics[]

\ Initializer for each array element
\ Initial array index on stack, which is autoincremented after each use
: /SM ( n smindex addr u addr u - n+1 ) 5 PICK >R
   R@ SysMetrics[] Desc PLACE
   R@ SysMetrics[] Label PLACE
   R> SysMetrics[] Index !
   1+ ;

\ Index Label / Description
0 SM_CXSCREEN S" SM_CXSCREEN"
                        S" Screen width in pixels" /SM
   SM_CYSCREEN S" SM_CYSCREEN"
                        S" Screen height in pixels" /SM
   SM_CXVSCROLL S" SM_CXVSCROLL"
                        S" Vertical scroll width" /SM
   SM_CYHSCROLL S" SM_CYHSCROLL"
                        S" Horizontal scroll height" /SM
   SM_CYCAPTION S" SM_CYCAPTION"
                        S" Caption bar height" /SM
   SM_CXBORDER S" SM_CXBORDER"
                        S" Window border width" /SM
   SM_CYBORDER S" SM_CYBORDER"
                        S" Window border height" /SM
   SM_CXDLGFRAME S" SM_CXDLGFRAME"
                        S" Dialog window frame width" /SM
   SM_CYDLGFRAME S" SM_CYDLGFRAME"
                        S" Dialog window frame height" /SM
   SM_CYVTHUMB S" SM_CYVTHUMB"
                        S" Vertical scroll thumb height" /SM
   SM_CXHTHUMB S" SM_CXHTHUMB"
                        S" Horizontal scroll thumb width" /SM
   SM_CXICON S" SM_CXICON"
                        S" Icon width" /SM
   SM_CYICON S" SM_CYICON"
                        S" Icon height" /SM
   SM_CXCURSOR S" SM_CXCURSOR"
                        S" Cursor width" /SM
   SM_CYCURSOR S" SM_CYCURSOR"
                        S" Cursor height" /SM
   SM_CYMENU S" SM_CYMENU"
                        S" Menu bar height" /SM
   SM_CXFULLSCREEN S" SM_CXFULLSCREEN"
                        S" Full screen client area width" /SM
   SM_CYFULLSCREEN S" SM_CYFULLSCREEN"
                        S" Full screen client area height" /SM
   SM_CYKANJIWINDOW S" SM_CYKANJIWINDOW"
                        S" Kanji window height" /SM
   SM_MOUSEPRESENT S" SM_MOUSEPRESENT"
                        S" Mouse present flag" /SM
   SM_CYVSCROLL S" SM_CYVSCROLL"
                        S" Vertical scroll arrow height" /SM
   SM_CXHSCROLL S" SM_CXHSCROLL"
                        S" Horizontal scroll arrow width" /SM
   SM_DEBUG S" SM_DEBUG"
                        S" Debug version flag" /SM
   SM_SWAPBUTTON S" SM_SWAPBUTTON"
                        S" Mouse buttons swapped flag" /SM
   SM_CXMIN S" SM_CXMIN"
                        S" Minimum window width" /SM
   SM_CYMIN S" SM_CYMIN"
                        S" Minimum window height" /SM
   SM_CXSIZE S" SM_CXSIZE"
                        S" Min/Max/Close button width" /SM
   SM_CYSIZE S" SM_CYSIZE"
                        S" Min/Max/Close button height" /SM
   SM_CXFRAME S" SM_CXFRAME"
                        S" Window sizing frame width" /SM
   SM_CYFRAME S" SM_CYFRAME"
                        S" Window sizing frame height" /SM
   SM_CXMINTRACK S" SM_CXMINTRACK"
                        S" Minimum window tracking width" /SM
   SM_CYMINTRACK S" SM_CYMINTRACK"
                        S" Minimum window tracking height" /SM
   SM_CXDOUBLECLK S" SM_CXDOUBLECLK"
                        S" Double click x tolerance" /SM
   SM_CYDOUBLECLK S" SM_CYDOUBLECLK"
                        S" Double click y tolerance" /SM
   SM_CXICONSPACING S" SM_CXICONSPACING"
                        S" Horizontal icon spacing" /SM
   SM_CYICONSPACING S" SM_CYICONSPACING"
                        S" Vertical icon spacing" /SM
   SM_MENUDROPALIGNMENT S" SM_MENUDROPALIGNMENT"
                        S" Left or right menu drop" /SM
   SM_PENWINDOWS S" SM_PENWINDOWS"
                        S" Pen extensions installed" /SM
   SM_DBCSENABLED S" SM_DBCSENABLED"
                        S" Double-Byte Char Set enabled" /SM
   SM_CMOUSEBUTTONS S" SM_CMOUSEBUTTONS"
                        S" Number of mouse buttons" /SM
   SM_SECURE S" SM_SECURE"
                        S" Security present flag" /SM
   SM_CXEDGE S" SM_CXEDGE"
                        S" 3-D border width" /SM
   SM_CYEDGE S" SM_CYEDGE"
                        S" 3-D border height" /SM
   SM_CXMINSPACING S" SM_CXMINSPACING"
                        S" Minimized window spacing width" /SM
   SM_CYMINSPACING S" SM_CYMINSPACING"
                        S" Minimized window spacing height" /SM
   SM_CXSMICON S" SM_CXSMICON"
                        S" Small icon width" /SM
   SM_CYSMICON S" SM_CYSMICON"
                        S" Small icon height" /SM
   SM_CYSMCAPTION S" SM_CYSMCAPTION"
                        S" Small caption height" /SM
   SM_CXSMSIZE S" SM_CXSMSIZE"
                        S" Small caption button width" /SM
   SM_CYSMSIZE S" SM_CYSMSIZE"
                        S" Small caption button height" /SM
   SM_CXMENUSIZE S" SM_CXMENUSIZE"
                        S" Menu bar button width" /SM
   SM_CYMENUSIZE S" SM_CYMENUSIZE"
                        S" Menu bar button height" /SM
   SM_ARRANGE S" SM_ARRANGE"
                        S" How minimized windows arranged" /SM
   SM_CXMINIMIZED S" SM_CXMINIMIZED"
                        S" Minimized window width" /SM
   SM_CYMINIMIZED S" SM_CYMINIMIZED"
                        S" Minimized window height" /SM
   SM_CXMAXTRACK S" SM_CXMAXTRACK"
                        S" Maximum draggable width" /SM
   SM_CYMAXTRACK S" SM_CYMAXTRACK"
                        S" Maximum draggable height" /SM
   SM_CXMAXIMIZED S" SM_CXMAXIMIZED"
                        S" Width of maximized window" /SM
   SM_CYMAXIMIZED S" SM_CYMAXIMIZED"
                        S" Height of maximized window" /SM
   SM_NETWORK S" SM_NETWORK"
                        S" Network present flag" /SM
   SM_CLEANBOOT S" SM_CLEANBOOT"
                        S" How system was booted" /SM
   SM_CXDRAG S" SM_CXDRAG"
                        S" Avoid drag x tolerance" /SM
   SM_CYDRAG S" SM_CYDRAG"
                        S" Avoid drag y tolerance" /SM
   SM_SHOWSOUNDS S" SM_SHOWSOUNDS"
                        S" Present sounds visually" /SM
   SM_CXMENUCHECK S" SM_CXMENUCHECK"
                        S" Menu checkmark width" /SM
   SM_CYMENUCHECK S" SM_CYMENUCHECK"
                        S" Menu checkmark height" /SM
   SM_SLOWMACHINE S" SM_SLOWMACHINE"
                        S" Slow processor flag" /SM
   SM_MIDEASTENABLED S" SM_MIDEASTENABLED"
                        S" Hebrew and Arabic enabled flag" /SM
\ SM_MOUSEWHEELPRESENT S" SM_MOUSEWHEELPRESENT"
\ S" Mouse wheel present flag" /SM
\ SM_XVIRTUALSCREEN S" SM_XVIRTUALSCREEN"
\ S" Virtual screen x origin" /SM
\ SM_YVIRTUALSCREEN S" SM_YVIRTUALSCREEN"
\ S" Virtual screen y origin" /SM
\ SM_CXVIRTUALSCREEN S" SM_CXVIRTUALSCREEN"
\ S" Virtual screen width" /SM
\ SM_CYVIRTUALSCREEN S" SM_CYVIRTUALSCREEN"
\ S" Virtual screen height" /SM
\ SM_CMONITORS S" SM_CMONITORS"
\ S" Number of monitors" /SM
\ SM_SAMEDISPLAYFORMAT S" SM_SAMEDISPLAYFORMAT"
\ S" Same color format flag" /SM
DROP

****************************************************************************
************
****************************************************************************
************

-----Original Message-----
From: SF Talk [mailto:sftalk_at_forth.com]
Sent: Thursday, October 28, 1999 6:54 PM
To: SF Talk
Subject: Structures with string data

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 Wed Oct 27 1999 - 18:52:55 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.