I would be grateful if someone could help me write a script which updates a query list say every 10 seconds.
Public Sub Mimic_Refresh
Mimic.Layers("Mimic").Item("Lst_1").sql = Mimic.Layers("Mimic").Item("Lst_1").sql &" "
But does not work.
Grateful for any help
Solved! Go to Solution.
That's not what scripting is for, it is single threaded and can be aborted by another scripting running.
What is the SQL doing/showing? If you're referencing database objects and include the id field the row content should update automatically. If its a data table/grid then it won't auto update.
Perhaps if you look at this link
This is close to what I wish to achieve only I would like to automate the query refresh at regular intervals.
surely the code fragment detailed in the link could be placed within a mimic script loop incorporating a sleep/wait command after a refresh for x amount of seconds before looping again?
Thank you for your reply.
I agree with Adam, this is not what scripting is intended for.
If you want an SQL query on the page to be updated every so often, then you will need the animation property for it to change. This can be done by having the SQL animation include a meaningless point reference where that point is updated every X seconds.
The demo database has a horrible 'clock' example which has a noisy point that does something every second (I believe). So you could add that to the animation.
'SELECT stuff you care about
FROM place you care about
WHERE things you care about are true AND (' + "PointValue" ' > -1 OR TRUE)'
In this way the query is different every x seconds, but the result of the query is still the same.
Many embedded lists will refresh automatically - ones which directly query database tables descending from CDBObject, such as points and RTUs. Lists such as events and historic data will not.
As an aside, if you DON'T want a query to refresh automatically there's an 'interest' checkbox on the embedded list object's properties.
Naturally, causing too regular refresh using the SQL animation method will cause extra database load, plus operator distraction as lists refresh - the trick is to find the right frequency - perhaps there is some other database item which changes, and you can JOIN using that?
The SQL animation method also requires you to take careful note of your " and ' characters, and to escape them as needed. This can get tricky when editing in the animation box, so using Notepad and cutting/pasting may help you.
The ' is used for string literals in animations and also for the SQL, so double-up single quotes for SQL within the single quotes.
I had asked for something similar quite a while back. Probably buried somewhere in the old forums. Mine was slightly more complicated due to have multiple embedded lists on the mimic I wanted to all refresh at the same time automatically. I was able to create a button on the Mimic that would refresh all of the embedded lists, that uses a small bit of script in the background.
I got this to work with Animations on the embedded list. On the "SQL" property use a IIF( "~Global.List Update Trigger" > 0, 'SELECT * FROM CDBPoint, '' ) Then just toggle that Update Trigger with a Logic Program using the normal timer properties of the logic program.