Hi all,
I’d like to extract all strings whose description start with “WR” , so that they are not printed in my report.
I’ve tried statements like: IF record.description = ‘WR*’ THEN
CurrReport.SKIP;
Qn, how do I extract such strings and avoid printing them.
thanks.
Joerg
2
You should use the function STRPOS for that:
STRPOS (String)
Use this function to search for a substring inside a string.## Position := STRPOS(String, SubString)
Position
Data type: integer
The position of SubString in String. If the system cannot find SubString, it returns zero (0).
String
Data type: text constant or code
The string you want to search in.
SubString
Data type: text constant or code
The string you want to search for. The STRPOS function is case-sensitive.
Comments
The STRPOS function only returns the position of the first occurrence of the substring.
In your case this would be:
If STRPOS(record.description,‘WR’) = 1 then
CurrReport.skip.
Hi Joerg.
Thanks for the insight! It works!!
kriki
4
Or also:
IF COPYSTR(record.description,1,2) = ‘WR’ then
CurrReport.SKIP;
And maybe, you should put (in case you can have both upper- as lowercase:
IF UPPERCASE(COPYSTR(record.description,1,2)) = ‘WR’ then
CurrReport.SKIP;
You don’t have to use the STRPOS function. You can use filters, and by using filters, you can avoid having to loop through all of your records.
Record.setfilter(descriptoin,’%1’,‘WR*’) ;
Record.findset(false,false) ;
will return all records whose description starts with WR.
Unfortunately, I do not thing you can use the “NOT” operator with the “*” operator.