GLBasic forum

Main forum => GLBasic - en => Topic started by: mentalthink on 2010-Feb-19

Title: How pass variables from client to host whit NetCommands
Post by: mentalthink on 2010-Feb-19
HI there, IÃ,´ve got a question, about how pass variables from a client GLbasic to host made too whit glbasic.

I donÃ,´t know if I stay wronged, but this is can make whit the comand netsendmsg?Ã,¿, the trouble I think is when make netgetmsg$(), this is a string, and donÃ,´t have numeric values.

Thanks.
Title: Re: How pass variables from client to host whit NetCommands
Post by: Kitty Hello on 2010-Feb-19
Yes, it sends strings. If you want to write binary data, just convert your data into a string:

Code (glbasic) Select


LOCAL out$ = PackInt$(1234) + PackInt$(1000000)


STDOUT "pop: "+UnPackInt(out$)+"\n"
STDOUT "pop: "+UnPackInt(out$)+"\n"
KEYWAIT


FUNCTION PackInt$: i%
LOCAL a$
INLINE
*(int*)a_Str.getbuffer(5) = i;
a_Str.setlength(4);
ENDINLINE
RETURN a$
ENDFUNCTION



FUNCTION UnPackInt%: BYREF str$
INLINE
int i = *(int*)(str_Str.getbuffer(4)+LEN(str_Str)-4);
str_Str = MID_Str(str_Str, 0, LEN(str_Str)-4);
return i;
ENDINLINE
ENDFUNCTION


Tags: binary, integer to string

ENDFUNCTION
Title: Re: How pass variables from client to host whit NetCommands
Post by: mentalthink on 2010-Feb-19
Thanks Gernoot, I will try after, thanks for the code.

Best Regards
Iván J.