It took a while, but this case is now resolve. The message resulted from this script line:
set idleTime to (do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'") as integer
By replacing the “as integer” by the “round” function that message stopped. I don’t know why one statement works while the other doesn’t, but I can now go forward with the rest of the script.
Great example of the problems a user can create if they ignore the current decimal separator setting on numeric strings.
As a result, the users above cannot coerce a string into a real or integer. The reason is that ioreg returns a string with a period (“.”), and in the computer settings for the decimal separator the user has a comma (“,”) or something else.
Therefore, in order to coerce the result of ioreg into a real (or an integer), you have to work a little:
on getIdleTimeAsReal()
-- get IDLE time in its text form (as is)
set idleTime to do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'"
-- determine automatically current setting for decimal separator
set decimalSeparator to middle character of (0.0 as text)
-- replace decimal separator with appropriate one
if decimalSeparator is not "." then
set ATID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set idleTime to text items of idleTime
set AppleScript's text item delimiters to decimalSeparator
set idleTime to idleTime as text
set AppleScript's text item delimiters to ATID
end if
-- now you can coerce the text to the number
set idleTime to idleTime as real
end getIdleTimeAsReal
my getIdleTimeAsReal()
.
.
NOTE:
Getting the idle time as an integer is easy:
set idleTimeAsInteger to (do shell script "/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'") as integer