Equivalences ASCII <-> Rawkey for barcodes scanner

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Equivalences ASCII <-> Rawkey for barcodes scanner

Post by bangkok » Tue Sep 02, 2008 9:11 pm

I would like to try to understand the weird logic of Rawkey.

Why not using regular ASCII values ?

My point : Rawkey uses (apparently) a code of 5 digits for special keys and 2 or 3 digits for regular characters.

For instance 65293 for CR (carriage return).

Where I can find an equivalence table ASCII <-> Rawkey system ?

I'm using a barcode scanner with special prefix and sufix. This system uses regular ASCII (extended). For instance, I set ASCII(160) as my prefix.

So to summarize :
-I'm able to catch the rawkey codes. But my problem is after : how decode them in regular ASCII ?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Wed Sep 03, 2008 10:10 am

The problem is that ASCII is equal on all platforms only for very few control chars (like return, space and the most basic sentence signs) english chars and zero to nine. After that, it's open to guessing what a certain number actually will result in for the user. Therefore it's best to create your list yourself. The easiest way would be to make a list of the chars you'll actually use, and the ACSCII representing them on the barcode scanner. Then you could do something like this (untested):

Code: Select all

--assuming a list of <char>,<asciinumber>
on mosueUp
  repeat for each line theLine in field "asciiList"
    put chartonum(item 1 of theLine) into conversionArray[item 2 of theLine]
  end repeat
  put conversionArray[65]--should be the same, 65
  put numtochar(conversionArray[65]) --rev equivalent of ascii 65 = A
end mouseUp
Of course the example given is a bit boring, but for more interesting characters, the numbers will be different.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Post by bangkok » Thu Sep 04, 2008 6:28 pm

Thanks. This is actually what I did.

First I thought that I was missing a special function or command.
:D

Maybe in future versions of Revolution ?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Thu Sep 04, 2008 10:39 pm

As I explained no, that can't be done.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Post Reply