Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

TimeIntoInterval Compiler warnings


kcopeland Jul 19, 2016 10:46 PM

CR1000 with OS29.

I'm getting a compiler warning when using this code:

Const localtime_c = False
Const timezoneoffset_c = -6 * 3600
Public bool As Boolean
'Main Program
BeginProg
 Scan (1,Sec,0,0)
    If TimeIntoInterval((IIF(localtime_c, 0, timezoneoffset_c / 3600) + 24) MOD 24, 24, Hr) Then bool = false Else bool = true
 NextScan
EndProg

[Version]C:\Campbellsci\Lib\Compilers\CR1Comp.exe VERSION:CR1000.Std.29  DATE:02/16/2016

line 10: Warning: Parameter will truncate to the nearest integer.
line 10: Warning: Parameter will truncate to the nearest integer.

I understand it's just a warning but I use code like this multiple times and so I get around 16 warnings.  The help says to declare these values as Long but I can't do that when using a constant. (with out declaring public variables and setting them equal to the constants).   


JDavis Jul 20, 2016 10:53 PM

Const localtime_c = False
Const timezoneoffset_c = -6 * 3600
Public bool As Boolean
Dim tempLong As Long
'Main Program
BeginProg
Scan (1,Sec,0,0)
tempLong = (IIF(localtime_c, 0, INT(timezoneoffset_c / 3600)) + 24) MOD 24
If TimeIntoInterval(tempLong, 24, Hr) Then bool = false Else bool = true
NextScan
EndProg


DAM Jul 20, 2016 11:09 PM

Just an FYI : with the next release of the OS you will be able to use the Ctype instruction as follows:

If TimeIntoInterval(Ctype((IIF(localtime_c, 0, timezoneoffset_c / 3600) + 24) MOD 24, long), 24, Hr) Then bool = false Else bool = true

Until then you will have to do as JDavis suggests and use the intermediate variable.

Log in or register to post/reply in the forum.