hi,
> I can say, somebyte=ASC("x"), but is it possible to quickly assign a two-byte
> string to a typical two-byte short?
>
> I'm sure this can be done with some lengthy function but (as most
> programmers should) I have a need for efficiency. I'm not concerned with
> character set mishaps for people with different language settings, as the
> app will be virtualized in a strict environment.
>
> Also in general I am extremely interested in how to quickly assign values
> from one datatype to a different one. Does GAMBAS have a convention for this
> outside of functions like ASC?
>
> -----
> Kevin Fishburne, Eight Virtues
> www: http://sales.eightvirtues.com http://sales.eightvirtues.com
> e-mail: mailto:[email protected] [email protected]
> phone: (770) 853-6271
hum, this shouldn't be so diffcult and even if there were a function, it
won't be more efficient than this one:
PUBLIC FUNCTION GetShort(sWord AS String) AS Short
RETURN Mid$(sWord, 1, 1) * 256 + Mid$(sWord, 2, 1)
END
i haven't tried it but i think it should work... but i think there is
the problem that shorts in gambas are -32.768 <= Short <= +32.767 and i
don't know if there's a possibility to make them unsigned like in c, but
if you only want to deal with standard ascii chars (to 127) the highest
value will be 127 * 256 + 127 = 32639 and this fits in the short's space.
i hope, this is all right.
regards,
tobi
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user