Hello
I need to turn Hex number to decimal values in survey123 connect for one question?
do we have any formula or work around to achieve this?
Best
You could use the parseInt() javascript function to convert hex numbers to integers.
function hexToInt(hex) { return parseInt(hex, 16); }
Then use the survey123 calculation:
pulldata("@javascript", "functions.js", "hexToInt", ${your_hex_field})
While java can do this with less steps, not everyone can use Java in their environment. To do this inside of S123 natively, you can use the attached (at least as a starting point).
input_txtYour HEX input (only built it for 4 digits, but didn't add a bind::esri:fieldLength).
input_stuffThese calculates isolate the positions of the characters. E.g., substr(${input_txt}, 2, 3) will grab the third character of the string within input_txt. It starts from 0, and reads left to right.
convert_stuffWill convert the alpha character (A to F) into a decimal number (10 to 15), or return the decimal number (0 to 9) without changing it.
calculate_stuffmultiplies the number by 16^x, where x is the position (This will explain better than me)
output_txtYour decimal output
S123:
Verification:
Two things:
Is everyone using the form in your organization? If so, you could use a JavaScript function, JS can convert hex to decimal pretty easily
Should be doable via calculates.
From https://www.binaryhexconverter.com/hex-to-decimal-converter
@MobiusSnake Hey unfortunately I don't know JS. 😞
Thanks @abureaux do you know how can I use this calculation in survey123 Calculate field.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.