× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




I'm having trouble getting Regexec() to compile in my program. I'm using
the example regex_h that Scott put out a couple years ago. I've searched
archives but can't find any instances where people are trying to use the
returned matches array. Most are just using it as a validation process for
emails.

My intention with the code below is to run the regexec and loop through the
matches in order to do something with those words that matched the pattern.
However, the compiler is giving me a message about the 4th parameter not
being able to be passed by reference. I am stuck on this one and can't seem
to figure out what silly mistake I'm making. Can anyone help me out?

The compiler error...

*RNF7542 30 001060 Parameter 4 is not valid as a parameter passed
by

reference.

*RNF7542 30 1 Parameter cannot be passed by reference when it can be

changed during the call.

Here is what I have...

d buffer s 1000a inz
d pattern s 512a inz('(?:\s+)(?:#)\s{0,5}([0-9a-z]+)')
d reg ds likeds(regex_t)
d numMatches s 10u 0 inz(100)
d matches ds likeds(regmatch_t) dim(100)
d rc s 10i 0
d len s 5u 0 inz
d foundWord s 100a inz

//Compile the regular expression
rc = regcomp(reg :pattern :REG_EXTENDED + REG_ICASE + REG_NOSUB);
if rc <> 0;
return;
endif;

//Execute the regular expression to find pattern matches
rc = regexec(reg :%trim(buffer) :numMatches :matches :0);
if rc = 0;

//Loop through each of the matched words
for i = 1 by 1 to numMatches;

//Get the length of the found word
len = matches(i).rm_eo - (matches(i).rm_so + 1);

//Extract the word found to match the pattern
foundWord = %subst(buffer :matches(i).rm_so+1 :len);

endfor;

endif;


Thanks,
Robert Newton
EDPS
Electronic Data Processing Services
System Owner
804-353-1900 x2256
rnewton@xxxxxxxxxxxx



This communication and any transmitted documents are intended to be confidential. If there is a problem with this transmission, please contact the sender. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.