Stashing 3 or 4 characters into a text for db storage

Dr. Hawkins dochawk at gmail.com
Sat Jul 21 12:23:30 EDT 2012


As I'm adjusting my data to get ready for postgreSQL instead of
SQLite, I've pretty much settled on having two, rather than one, data
tables.

Dollar amounts  and other simple things will go into one table, while
text will go into another with a VACHAR type.

I have various calculated properties that are typically set as either
single letter strings or three character strings.

I have a custom property datTyp on fields to keep track of what they
use--D for Dollars (store as cents as intenger); I for integers; B for
boolean (store as 1/0);  T1 for single characters, has an obvious
ascii conversion.

But what about stashing 3 or four characters?  Obviously there's
enough bits in a four byte integer to do this, but is there a built in
function, by any chance, that would handle this?  (I'm having
flashbacks to the way we stashed ints & floats into fields in BASIC-80
5.0 . . . which would be perfect for this).

I guess there's
   put numtochar(tVal mod 65536 ) & numtoChar(tval bitand 65279 / 256)
& numToChar(tval bitAnd 255) into tStr

and
  put 65536* charToNum(char 1 of tStr) + 256 * charToNum(char 2 of
tStr) + charToNum(char 3 of tStr) into tVal

but they seem so awkward for converting something into itself . . .

-- 
The Hawkins Law Firm
Richard E. Hawkins, Esq.
(702) 508-8462
HawkinsLawFirm at gmail.com
3025 S. Maryland Parkway
Suite A
Las Vegas, NV  89109




More information about the use-livecode mailing list