Hello all!

i was having some trouble with declaring a string and its size :(, and i was hoping that someone could help me :)

i tried writing a macro /w my almost non-existent macro-writing skills (i know, shameful) to do this, but the characters like nulls messed it up (it took them as a parameter)

anyway, my problem is basically to create an error message by defining it once and outputting it to a winsocket. the "send" function requires the size of the data as one of its operands, but since my error messages are constant, there is no need (and indeed, it is a waste) to dynamically find the size of the error message. without defining the entire text of a message twice in a CONST and in the data section, i am trying to have one variable storing the message and another storing the length.

in otherwords, something like this:



.data
Error404 db "File Not Found"
.const
Error404Size textequ @SizeStr(Error404)


any help would be appreciated! :)
Posted on 2002-06-08 14:26:20 by jademtech
.data

Error404 db "File Not Found", 0
.const
Error404Size EQU SIZEOF Error404
This will give you 15 including the NULL terminator. I think SizeStr only works only on a string inside it's bracket
Error404Size EQU @SizeStr(<Hello>)
This one will give you 5.
Posted on 2002-06-08 14:47:09 by stryker
For this I would do
invoke send, Sock, addr Error404, (LENGTHOF Error404-1), 0
I don't think the brackets are realy necesary though
Posted on 2002-06-08 14:53:01 by Kudos
ErrorString MACRO _name:REQ,y:VARARG

CONST segment
_name db y,0
_name&_Length EQU SIZEOF _name
CONST ends
ENDM


ErrorString Error404, < \
"Very bad thing has happened.",10,13, \
"You get no pudding!">
Posted on 2002-06-08 15:07:41 by bitRAKE
thanks, all!

i've got me some puddin', though, bitRAKE :)
Posted on 2002-06-08 15:09:43 by jademtech