Hello![]()
I am having some problem to convert Decimal to Hex whit two imput Box, can somebody help me whit this, please?![]()
Best Regards, steven![]()
Professional Software Development Tools
Hello![]()
I am having some problem to convert Decimal to Hex whit two imput Box, can somebody help me whit this, please?![]()
Best Regards, steven![]()
Check this thread
http://www.indigorose.com/forums/sho...&highlight=hex
Tks yosik
Where can i place this code for this to work![]()
Code:function Dec2Hex(nValue) if type(nValue) == "string" then nValue = String.ToNumber(nValue); end nHexVal = string.format("%X", nValue); -- %X returns uppercase hex, %x gives lowercase letters sHexVal = nHexVal..""; return sHexVal; end
i have a Imput1 and a input2 and no button?
Sorry about the english![]()
function can be in the global function panel. But you have to call it when you want it.
Make a button which will call upon the function and send the result to the second input object.
Yossi
hello again and tanks for your help and your time![]()
i dont understand very well all words from those examples that i tried to read here and it very dificult to me to make those code to work. Can you make a example of this code in a *.apz file for me?
I know that is not the right way, but for me thats more easy to understand how that realy works.
Tanks again for your help![]()
Originally Posted by yosik
![]()
How can i do that?Originally Posted by yosik
![]()
You have 3 objects on your page:
Input1 (this is where you input your decimal number)
Input2 (this is where you will see the converted number to hex)
Button1 (to launch your conversion)
In your Global functions, put the following:
function Dec2Hex(nValue)
if type(nValue) == "string" then
nValue = String.ToNumber(nValue);
end
nHexVal = string.format("%X", nValue); -- %X returns uppercase hex, %x gives lowercase letters
sHexVal = nHexVal.."";
return sHexVal;
end
In your onClick event of your button object, put the following:
decNmbr = String.ToNumber(Input.GetText("Input1"));
Dec2Hex(decNmbr);
Input.SetText("Input2",sHexVal);
That's it
Yossi
Tanks for your time and help yosik's![]()
![]()
![]()
![]()
![]()
![]()
hello again![]()
Just a little explanation more please..
Whem a place a value for example 4 the result in Hex is 4, but i want that the display result wase 0004, how can we do that?
Examples:
DEC ------ HEX ------------- RESULT that i want to look like
1 --------> 1 ---------------- 0001
10 -------> A ---------------- 000A
20 -------> 14 --------------- 0014
5000 ----> 1388 ------------- 1388
when the result dosent have 4 numbers it should place zeros just like in the examples.
Tks again for your tine whith me![]()
LUA has a built in function called string.format. You can use this to force a string to four characters with leading zeros.
Input.SetText("Input2", string.format("%04s", sHexVal));
Tigg
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
Ok y understand now![]()
Tanks TJ_Tigger and yosik![]()
![]()
![]()
When it comes to AMS, those two guys are a "One Two Knockout". I just have not figured out who is "one" and who is "two."
@ 'Tig and Yosik
Intrigued
Right backatcha, Intrigued...![]()
Yossi