Features, discussions, tips, tricks, questions, problems and feedback

Agent scripting


I have make a script in side a screen to get data form a plc to a txt file. Now I needs to by this screen always open sothat the script runs.

Using Agent script the scrip runs al the time.

But i don’t get this to work.

Have some don this before.

This what I have make in de script white a grafic form

and on agent script.

Who can show me what i’m doning wrong.

Thank you.

Are you trying to store an agent value in a text file? Do you want this to run on the client or the server?

If you are specifically looking at storing agent values, the DBLOG agent may be a better option depending on your requirements.

Yes I’m store an agent value in a text file.
It needs to run always.

What the idea is:
Every minute when a machine is on automatic (Bit in plc, true) then every minute store value in a text file. But the text must always be the same.

Example on tuesday the production is on. Stored in text file. P1
Wensday production not.
Thuersday production is on. Stoerd in text file. P1

Is this better to do white DBLOG agent?

This can easily be done by using standard data logging. The logs can then also be provided to a chart/trend and exported to CSV. Data logging is available from the configurator:


Alternatively, the DBLOG Agent can be used to log the values to a SQL Database, if required.


Using the agent scripting to set a value in a plc to 0.

I wanne make this automaticley. For example at 00:00 every day.

Hoe can I get the system time in the agent script?


If it’s midnight it should be quite easy.
Just set the agent to run when tag change and as tag pick systeminfo.day, this will change only once a day at midnight

1 Like

I have done some tests with this way of logging.
But I have some problems with it.

What are the settings to get it to work fine, logging every minute for 20 years in the same file?

And how do I get the right output in a text file?

Can you let me know what I’m doing wrong?

A post was split to a new topic: Write data to text file

There is no direct way of logging to a text file (unless using the OleDB Excel CSV output connector).

However, please note that logging for extended periods into a text file is not recommended.

Rather log to a database or to native log files and export the data on a periodic basis.