char arrays in structs
[1/8] from: greggirwin:mindspring at: 4-Sep-2003 8:49
Does anyone have a better way to map char arrays in structs than
creating separate elements that take up the correct total amount of
space? e.g.
RASDIALPARAMSA
{
DWORD dwSize;
CHAR szEntryName[ RAS_MaxEntryName + 1 ];
...
RASDIALPARAMSA: make struct! [
dwSize [integer!]
szEntryName1 [char!]
szEntryName2 [char!]
szEntryName3 [char!]
szEntryName4 [char!]
...
-- Gregg
[2/8] from: petr::krenzelok::trz::cz at: 4-Sep-2003 20:04
Gregg Irwin wrote:
>Does anyone have a better way to map char arrays in structs than
>creating separate elements that take up the correct total amount of
<<quoted lines omitted: 12>>
> ...
>-- Gregg
gen-chars: func [word-name to-number /local buff i][
buff: copy ""
insert buff newline
for i 1 to-number 1 [append buff join word-name [i " [char!]"
newline]]
load buff
]
gen-blk-chars: func [to-number /local buff i][
buff: copy []
for i 1 to-number 1 [append buff #"^@"]
buff
]
GFL_COLORMAP: make struct! compose/deep [
(gen-chars "Red" 256)
(gen-chars "Green" 256)
(gen-chars "Blue" 256)
] none
-pekr-
[3/8] from: maarten:vrijheid at: 4-Sep-2003 20:51
A string! Is a char array (i.e. *char) but I guess you know that,
So... no
[Actually, a **char is a struct! with a string!]
--Maarten
[4/8] from: greggirwin:mindspring at: 4-Sep-2003 18:20
Hi Petr,
PK> gen-chars: func [word-name to-number /local buff i][
PK> ...
Thanks. I've already commandeered yours and Cyphre's method for
generating them (very slick BTW). :) I was just wondering if there was
a more direct representation. At least the words in the struct spec
don't contribute to the global name space.
-- Gregg
[5/8] from: nitsch-lists:netcologne at: 5-Sep-2003 18:17
Am Donnerstag, 4. September 2003 16:49 schrieb Gregg Irwin:
> Does anyone have a better way to map char arrays in structs than
> creating separate elements that take up the correct total amount of
<<quoted lines omitted: 11>>
> szEntryName4 [char!]
> ...
you can replace the struct with a string and use offsets.
IIRC i have a sample somewhere on this list.
But do not remember a good search-word :(
> -- Gregg
-Volker
[6/8] from: jvargas:whywire at: 5-Sep-2003 13:21
Volker,
Not quite sure if it is this one
http://www.escribe.com/internet/rebol/m31596.html
but I believe so. -- Jaime
On Friday, September 5, 2003, at 12:17 PM, Volker Nitsch wrote:
[7/8] from: greggirwin:mindspring at: 5-Sep-2003 11:19
Hi Volker,
VN> you can replace the struct with a string and use offsets.
VN> IIRC i have a sample somewhere on this list.
VN> But do not remember a good search-word :(
Hmmm. Pass a string of the correct size and then copy the parts out...
That might work. I'll have to look into it.
Thanks!
-- Gregg
[8/8] from: nitsch-lists:netcologne at: 5-Sep-2003 21:54
Thanks, Jaime, you remembered it :)
-Volker
Am Freitag, 5. September 2003 19:21 schrieb Jaime Vargas:
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted