NumGate changes at specific date/times

Discussion about Code Builder Builder and Winlog language support.
bctBCT76
Posts: 23
Joined: Wed Jun 24, 2015 11:39 am

NumGate changes at specific date/times

Postby bctBCT76 » Wed Jul 08, 2015 8:34 pm

Hello Guys,

is it any code I can use to write a different value at a specific date&time?
I would need to setup multiple changing time&date pseudo-randomic..
As an example I would like to change a value at sunset/dawn for a couple of months.
is it possible?
I might like also the usage of a chart (csv file reporting dates,times, values)..
I use Winlog lite not the pro version.

Thanks a lot

User avatar
admin
Site Admin
Posts: 302
Joined: Tue Nov 17, 2009 1:18 pm

Re: NumGate changes at specific date/times

Postby admin » Thu Jul 09, 2015 8:23 am

Hi,
you can use code like this:

Code: Select all

Function void mainLoopSetValue()
#startup
    While (WindowIsOpen())
        if (GetHour() == 20 && GetMinute() == 30 && GetSecond() == 0) then
            SetNumGateValue("Test", 0, Rand(100));
            SetNumGateValue("Test", 1, Rand(100));
            SetNumGateValue("Test", 2, Rand(100));
            SetNumGateValue("Test", 3, Rand(100));
            SetNumGateValue("Test", 4, Rand(100));
            SetNumGateValue("Test", 5, Rand(100));
        end

        Sleep(1000);
    end
end


Regards

bctBCT76
Posts: 23
Joined: Wed Jun 24, 2015 11:39 am

Re: NumGate changes at specific date/times

Postby bctBCT76 » Thu Jul 09, 2015 1:34 pm

Thanks a lot,

is there a limitation or a suggested limit on the number of "if/end" cycles I can put in the code?

Thanks

User avatar
admin
Site Admin
Posts: 302
Joined: Tue Nov 17, 2009 1:18 pm

Re: NumGate changes at specific date/times

Postby admin » Thu Jul 09, 2015 1:39 pm

Hi,
No, ther isn't any limitation. But when using infinite loop like:

Code: Select all

   While (WindowIsOpen())
      // Your code
      
      Sleep(1000);
   end

don't forget to enter at least one Sleep(milliseconds) function for avoid CPU overload.

Best Regards


Return to “Code - Code Builder”

Who is online

Users browsing this forum: No registered users and 1 guest