how to write HEX-values?

45 views
Skip to first unread message

Jemand der GerneAnonymBleibt

unread,
Mar 22, 2016, 12:29:50 PM3/22/16
to MIT App Inventor Forum
I other languages I can write decimal values and hex-values for numbers. In C you use "0x0A" for hexadecimal writing of decimal 10.
Is it possible in App Inventor?

Abraham Getzler

unread,
Mar 22, 2016, 1:28:09 PM3/22/16
to MIT App Inventor Forum
The only metacharacter in AI2 text blocks is \n for NewLine (also known as Line Feed), decimal 10.

However, there is a way to generate your own hex using a Web block.
See attached ...

The hexify() procedure will use a Web component block to generate a hex string.

The example shown generates hex of "FEFF", a Byte Order Marker.

Of course, use your own hex values.

ABG



BOM.png
hexify.aia
hexify.png

Abraham Getzler

unread,
Mar 22, 2016, 1:30:23 PM3/22/16
to MIT App Inventor Forum
Oh, there're also some math blocks that ostensibly do hex conversion, but it's all just strings.
Good for teaching about hex conversion, but not real hardware level hex.
ABG

Jemand der GerneAnonymBleibt

unread,
Mar 22, 2016, 2:53:30 PM3/22/16
to MIT App Inventor Forum
I don't wont to generate hex values I want to write instead of decimal because it is often better to see want for it used (in case of & | << >>)

Abraham Getzler

unread,
Mar 22, 2016, 3:15:43 PM3/22/16
to MIT App Inventor Forum
If you want to go the other way, look in the Web component blocks for URIEncode (Decode?).
ABG

Reply all
Reply to author
Forward
0 new messages