dpGet with dyn_string not working for configs

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
Search

Post Reply
3 posts • Page 1 of 1
tpjctrl
Posts: 89
Joined: Tue May 08, 2018 10:30 am

dpGet with dyn_string not working for configs

Post by tpjctrl »

I'm trying to run the following:

dyn_string PosAlertTextDP;
dyn_bool PosAlertText;

PosAlertTextDP[1] = "SYS1:DP1:_alert_hdl.._active";
PosAlertTextDP[2] = "SYS1:DP2.Pos:_alert_hdl.._active";
PosAlertTextDP[3] = "SYS1:DP3:_alert_hdl.._active";

// this doesn't work, PosAlertText remains empty
dpGet(PosAlertTextDP, PosAlertText);
DebugN(PosAlertText);

for(int i=1;i<=dynlen(PosAlertTextDP);i++)
{
dpGet(PosAlertTextDP, PosAlertText);
}

// dpGet for each single dyn array element works fine
DebugN(PosAlertText);

As mentioned in the code comments above, dpGet doesn't produce a result when used with the whole PosAlertTextDP dyn_string array, but it works fine when each element is processed on it's own.

Any ideas why the above fails? I've used dpGet to pull values (not config related parameters) from dps and passed the dp names using dyn_string and that works absolutely fine, but for some reason when I add ":_alert_hdl.._active" (or any other config) it returns nothing (dpGet doesn't return an error, so it seems to run fine).

tpjctrl
Posts: 89
Joined: Tue May 08, 2018 10:30 am

Re: dpGet with dyn_string not working for configs

Post by tpjctrl »

Aaaaaand to answer my own question, it's because not every one of those DPs in PosAlertTextDP actually has an alert handle, so the dpGet throws an error which is checkable via getLastError() (even though it returns a 0 which is odd). To make it work properly one has to first pull the "_type" alert config param from all DPs, and then on the ones that are non-zero, pull the relevant alert handle params.

User avatar
leoknipp
Posts: 2645
Joined: Tue Aug 24, 2010 7:28 pm

Re: dpGet with dyn_string not working for configs

Post by leoknipp »

The return parameter of dpGet() only gives the information if the syntax was correct.
As you have detected on your own you have to use getLastError() to check if the command was successful or not.

Best Regards
Leopold Knipp
Senior Support Specialist

Post Reply
3 posts • Page 1 of 1