Simple Math! - Printable Version +- Ewon Technical Forum (https://techforum.ewon.biz) +-- Forum: Development (https://techforum.ewon.biz/forum-50.html) +--- Forum: BASIC Script (https://techforum.ewon.biz/forum-52.html) +--- Thread: Simple Math! (/thread-258.html) |
Simple Math! - insyncs - 30-03-2017 Hi can you help please, Trying to compute some simple math in the ewon but I’m not getting anywhere with it. Have looked through reference manual, but cannot find a math example. “Running_Hours%” is a Dword, “ComAp_Running_Hours_MSB%” is an INT “ComAp_Running_Hours_LSB%” is an INT I cannot get any values from the calc into the “Running_Hours” tag, even if I use Running_Hours% =1 The % needs to be added at the end of the Tag as per the manual for an INT – doesn’t cover a DWord so % is probably wrong, have tries without also. Code in basic IDE: Code: $Running_Hours% = (65536 * $F_Running_Hours_MSB%) + $F_Running_Hours_LSB% All I want to do is put two 16bit values into a 32bit word. Cheers RE: Simple Math! - simon - 31-03-2017 There is no need to put a $ char in front of the variables unless it is a local variable of a function (which is not your case). See an example that works : Code: F_Running_Hours_MSB% = 195 RE: Simple Math! - insyncs - 31-03-2017 Hi, Thanks for the response. It doesnt work for me. a bit more info for you. the two tags below are modbus tags: F_Running_Hours_MSB% F_Running_Hours_LSB% I want to read the values from the modbus tags, then create a 32 bit value stored into Running_Hours%( Local memory variable?) hope that's clear? PS can you help me change my username so its not my email! Cheers RE: Simple Math! - insyncs - 01-04-2017 ok got there thanks. i some how deleted the format of the script template so i guess it wasn't being called. this is what i used in the end thanks. // Calc For Historical Report Running_Hours_MSB% = Running_Hours_MSB@ Running_Hours_LSB% = Running_Hours_LSB@ Running_Hours% = (65536 * Running_Hours_MSB%) + Running_Hours_LSB% F_Running_Hours@ = Running_Hours% PRINT Running_Hours% // Calc End If you could let me know about the username that would be grand. RE: Simple Math! - simon - 03-04-2017 Yes, I can. Now I changed it to marcus_insyncs. Tell me whether it is ok or not. RE: Simple Math! - insyncs - 07-04-2017 (03-04-2017, 10:02 AM)Simon Wrote: Yes, I can. Hi, Can you change it to just insyncs? thanks! RE: Simple Math! - simon - 10-04-2017 Done RE: Simple Math! - insyncs - 10-04-2017 (10-04-2017, 11:29 AM)Simon Wrote: Done Thanks |