Hello Guest it is April 13, 2021, 01:46:53 PM

Author Topic: Problem in front or behind the screen?  (Read 2280 times)

0 Members and 1 Guest are viewing this topic.

Re: Problem in front or behind the screen?
« Reply #10 on: April 30, 2017, 02:45:50 AM »
I looked at the keyboard-Panel - I don't see any suspicious things related to "o".
But to make things clear: I run mach4 from a virtualbox-VM no real windows pc

and I checked SecondsToTime:
When I saw the format-string "%04f" I knew that something went wrong. So I added an error-log which leads to
Code: [Select]
function SecondsToTime(seconds)
if seconds == 0 then
return "00:00:00.00"
else
local hours = string.format("%02.f", math.floor(seconds/3600))
local mins = string.format("%02.f", math.floor((seconds/60) - (hours*60)))
local secs = string.format("%04.2f",(seconds - (hours*3600) - (mins*60)))
                mc.mcCntlSetLastError(inst, "secs " .. secs)
return hours .. ":" .. mins .. ":" .. secs
end
end
you can see the result in the errorline of the attached screenshot.
I tested the same with lua outside of mach4 with the result, that lua does not support leading '0' on float formats.
A SecondsToTime function, that works as expected is a bit ugly:
Code: [Select]
function SecondsToTime(seconds)
   if seconds == 0 then
      return "00:00:00.00"
   else
      local hours = math.floor(seconds/3600)
      local mins = math.floor((seconds/60) - (hours*60))
      local tmp = seconds - (hours*3600) - (mins*60)
      local secs = math.floor(tmp)
      local rest = math.floor((tmp - secs) * 100)
      return string.format('%02d:%02d:%02d.%02d', hours, mins, secs, rest)
   end
end
« Last Edit: April 30, 2017, 02:48:33 AM by django013 »
Re: Problem in front or behind the screen?
« Reply #11 on: April 30, 2017, 03:19:48 AM »
Oups - I have to say sorry to lua.

The problem is not lua, but the format-string. The dot counts, so the right format string should be "%05.2f"
... with that format-string, it works from lua ;)
Re: Problem in front or behind the screen?
« Reply #12 on: April 30, 2017, 03:36:55 AM »
The macro-editor (mcLua) uses different codepage than mach4.
Any non-ascii-character gets displayed weired.