× 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.



When it comes to efficiency, I always want to know how often this is going to be run: 10's, 1000's, millions of time per mintue, per hour, what? Rule of thumb, don't sweat the small stuff.

If maximum performance is required, test different approaches on a large set of data.

Having said that, if I had to do it for maximum efficiency, I'd probably use the pointer approach. but I'm very comfortable with pointers.

Off the top of my head, I'd probably write a procedure that was passed the initial string as a variable string, and an index to where to start searching (the x'1c') for the end markers. It would return the extracted string and an index to the next x'1c', or zero if this was the end.

Then in an outer loop I'd call this procedure until zero is returned,

So internally in the procedure you can experiment with various techniques to see what is the most efficient.

On a totally different approach, you might look at the %SPLIT BIF.

Sam


On 6/3/2022 12:04 PM, Vinay Gavankar wrote:
Hi,

I was trying to write a routine to get a value of a field from a string.
The field starts with an identifier, which is x'1c' + 2 characters. The
field ends when either a new field starts with either x'1c', x'1d' or
x'1e', or if it is the last field in the string, it would have all spaces
after it.

Would it be more efficient to use %scan to find the start and end positions
and then %subst to extract the value, or use some sort of pointer code to
go thru the string character by character to do my own search? Or use a
combination of both?

My first scan to find the start of the field is simple. But to get the end
of field, I will have to do multiple %scans for each of the 3 possible
characters (unless I am missing something).

So would it be better to use %scan to find the start of the field, and then
use pointers to find the end.

I have never used pointers for this kind of thing, but I think it should be
possible.

Any thoughts or suggestions would be appreciated.
TIA
Vinay


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.