Hey everybody, how ya doing?

In my program, I'm trying to use STRUCs to ease the process of defining strings. In particular, I would like to make a table of font names. Fonts can be 32 bytes in length at most, so this is sort of what I was hoping to do:



FONTNAME STRUC
name db 32 dup (0)
FONTNAME ENDS

.data
FontTable FONTNAME <"Arial">
FONTNAME <"Times New Roman">
FONTNAME <"Courier">


but it won't compile... it gives me the error message: "Structure cannot be instanced" does anyone have an idea of how to do something like this?

P.S. I know I could just define the strings literally, but for my purposes it's handy to use offsets from FontTable that are multiples of 32. Right now, I'm just padding every string to 32 bytes like so

FontTable db "Arial"
db 27 dup (0)
Posted on 2002-04-28 19:45:03 by chorus
I think you should do:
FONTNAME struc
name db 32 dup (?)
FONTNAME ends

instead of instancing with 0.

Problem is, they won't necessarily be null terminated strings...
Posted on 2002-04-28 19:48:51 by AmkG
tried it already... same error. I was hoping to imply the null termination too :)

Maybe a macro... but I don't know if that would help if the structure had other fields, which I'm also considering... Besides, I can't say i've really used macros... :P

--Chorus
Posted on 2002-04-28 19:54:19 by chorus
  FONTNAME STRUC

[B][COLOR=red]name[/COLOR][/B] db 32 dup (0)
FONTNAME ENDS
Name is a reserved word - you'll have to use another.
	FONTNAME STRUC

_name db 32 dup (0)
FONTNAME ENDS

.data
FontTable FONTNAME \
{"Arial"},
{"Times New Roman"},
{"Courier"}
Works.
Posted on 2002-04-28 20:42:41 by bitRAKE
Thank you very much! Had no idea name was reserved... and now it compiles :) So much easier....

--Chorus
Posted on 2002-04-28 23:19:09 by chorus