Stashing 3 or 4 characters into a text for db storage

dunbarx at aol.com dunbarx at aol.com
Sat Jul 21 13:59:53 EDT 2012


Not sure I understand what you want, but are you married to having a single numeric string encode your three/four char data?


It would be so much easier to store them as direct strings, with something unambiguous as delimiters, maybe even a comma?


I am sure I am not getting this...


Craig Newman



-----Original Message-----
From: Dr. Hawkins <dochawk at gmail.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Sat, Jul 21, 2012 12:24 pm
Subject: Stashing 3 or 4 characters into a text for db storage


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

_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 



More information about the use-livecode mailing list