Hello,
My question is related to DP filtering using dpNames().
I have a list of DP:
ASENSOR1
BMOTOR2
CVALVE3
CENT_SENSOR1
CENT_MOTOR2
CENT_VALVE3
I would like to know if in the dpNames() function a pattern negation condition can be introduced.
// It does not work.
dyn_string ds = dpNames("*:{!CENT_}*", "Device");
// It does work, but it is not dynamic.
dyn_string ds = dpNames("*:{A,B,CV}*", "Device");
Thanks.
Best regards,
Luis Miguel BP.
DP filtering using dpNames (pattern negation condition)
- luis.bustamante
- Posts:30
- Joined: Thu Jan 24, 2019 8:11 am
DP filtering using dpNames (pattern negation condition)
Last edited by luis.bustamante on Thu Dec 09, 2021 9:53 am, edited 1 time in total.
- gschijndel
- Posts:376
- Joined: Tue Jan 15, 2019 3:12 pm
Re: DP filtering using dpNames (pattern negation condition)
Complex patterns are only possible with the 'regexp' functions, which unfortunately do not work on dyn_strings.
You could get all dps from the type and check with a for loop and 'regexpIndex("^(?!CENT_).+$", ...)' which dps match your filter.
You could get all dps from the type and check with a for loop and 'regexpIndex("^(?!CENT_).+$", ...)' which dps match your filter.
- luis.bustamante
- Posts:30
- Joined: Thu Jan 24, 2019 8:11 am
Re: DP filtering using dpNames (pattern negation condition)
Thank you very much for your response.
I will get all the records and remove the ones I don't need.
This is the simplest way I have found:
dyn_string ds = dpNames("*", "Device");
for (int i = ds.count(); i > 0 ; i--) if (ds.contains(":CENT_") || ds.contains(":_mp_")) dynRemove(ds, i); ds.sort();
Best regards,
Luis Miguel BP.
I will get all the records and remove the ones I don't need.
This is the simplest way I have found:
dyn_string ds = dpNames("*", "Device");
for (int i = ds.count(); i > 0 ; i--) if (ds.contains(":CENT_") || ds.contains(":_mp_")) dynRemove(ds, i); ds.sort();
Best regards,
Luis Miguel BP.