Interesting factoid

| | Comments (2)

Since some people seem to be unaware of this (especially since the documentation fails to point it out), there are some neat new datatypes that REALbasic supports (and has for a while now):

Currency -- this is a 64-bit number, expressed in mils. In essence, you have an integer part, and four decimal parts to the number, and it's used to express currencies in a very accurate manner.

Ptr -- this is a 32-pointer datatype. You use it whenever you want to work with on-the-metal pointers. But use it with caution as you are welcome to shoot yourself in the foot using the datatype.

CString -- this is a null-terminated ANSI C string (akin to a const char * in C). There is automatic conversion between an RB String type and the CString type. When this conversion happens, a null byte is appended onto the CString.

WString -- similar to the CString, this is an ANSI wide character string (akin to a const wchar_t * in C). Basically, it's a UTF-16 string. Similar to CString, when you automatically convert from a String to a WString, it is terminated with a null wchar_t.

PString -- moving right along, this is a Pascal string. Unless you work with Mac Classic, chances are you won't need this. It's a string with a one-byte length specifier followed by up to 255 characters of string data. Again, there is automatic conversion with the String datatype.

CFStringRef -- this is the "replacement" for the PString in that newer Mac declares use this string datatype. It's an opaque datatype, but there is automatic conversion with String.

That covers the new-ish datatypes that I think people may not be aware of. Any questions?

2 Comments

Would the currency datatype be useful for other fixed point operations? Also, does currency provide any kind of currency conversion?

It could be, but probably not since it's pretty trivial to make your own fixed point datatype by using Int64. And no, currency does no such craziness. It's a datatype, not a unicorn. ;-)

Leave a comment

Disclaimer

I'm currently an employee of REAL Software. My blog is mine. The opinions represented in this blog are mine as well and may not represent my employer's opinions. All original material is copyrighted and property of the author.

REALbasic® is a registered trademark of REAL Software, Inc. REAL SQL Server™ and Lingua™ are pending trademarks of REAL Software, Inc. All rights reserved.