3/9/2019 7:07 AM  
Joined: 2/22/2008 Last visit: 10/15/2019 Posts: 1134 Rating: (84) 
I don't know the syntax of Java script, maybe it is similar to C++ Let us define following variables: Declare variables as needed by Java script, then calculate as follows: OM =EntryTime % 10; // extracting the 4 from 1234 Maybe anyone know, how to insert such operations in Java script with the right syntax. The "%" is the modulo function to get the rest by deviding. If you have another entry format e.g. separated hours and minutes, this is no problem. Just declare other variables and use the same principle. Regards, Scorp

3/11/2019 12:05 PM  
Joined: 4/4/2016 Last visit: 10/13/2019 Posts: 39 Rating: (1) 
Hi Scorp, Converting from Hex to decimal is well understood. How would you make the opposite , convert from decimal do Hex ? How would you write the script in C++ ? Thanks, M D 
3/11/2019 2:23 PM  
Joined: 2/22/2008 Last visit: 10/15/2019 Posts: 1134 Rating: (84) 
I have described the converter from dec to hex in my last entry. You have a decimal value 1234, which should be the time 12:34h and get the decimal value 4660, which should be the hexadecimal representation $1234. If you mean anything else, then describe clearly. I have asked, from where the value comes. Do you have one or two entry fields as variables ? Regards, Scorp 
3/12/2019 7:31 AM  
Joined: 2/22/2008 Last visit: 10/15/2019 Posts: 1134 Rating: (84) 
Let's try another way. I would like to have 2 entry fields, therefore we define following variables: EH = entry hours in decimal EM = entry minutes in decimal TH = tens of hours in decimal OH = ones of hours in decimal TM = tens of minutes in decimal OM = ones of minutes in decimal LT = Logo time in hexadecimal representation AUX = auxiliary variable First way, EH and EM is given, LT has to be calculated OH = EH % 10; TH = (EHOH) / 10; OM = EM % 10; TM = (EMOM / 10; LT = 4096 * TH + 256 * OH + 16 * TM + 1 * OM; Second way, LT is given, EH and EM has to be calculated OM = LT % 16; AUX = (LT  OM) / 16; TM = AUX % 16; AUX = (AUX  TM) / 16; OH = AUX % 16; TH = (AUX  OH) / 16; EH = TH * 10 + OH; EM = TM * 10 + OM; Regards, Scorp 
This contribution was helpful to1 thankful Users 
3/12/2019 4:01 PM  
Joined: 4/4/2016 Last visit: 10/13/2019 Posts: 39 Rating: (1) 
Hi Scorp, Sorry for not being clear. Thank you very much for such complete explanation. Now i will try find a way to " translate" your code to Java script. Regards, MD 
3/12/2019 4:47 PM  
Joined: 2/22/2008 Last visit: 10/15/2019 Posts: 1134 Rating: (84) 
The mathematical operations of my example are available in Java and similar in C++, but i don't know, how to insert in node red dashboard or the right syntax. I have never programmed Java either node red dashboard until now. Therefore you only can see the mathematical principles. Regards, Scorp 
3/22/2019 1:01 PM  
Joined: 4/4/2016 Last visit: 10/13/2019 Posts: 39 Rating: (1) 
Hi Scorp, Based in your explanation find in attachment nodered node function to convert decimal to Hex > Hour representation. Change var newMsg = { payload: EM} for getting Hex > minutes. Regards, Thank you for your help. MD AttachmentDecToHexHour.txt (6 Downloads) 
This contribution was helpful to1 thankful Users 