Page 1 of 1

Does AmigaDOS ParsePattern() do anything?

Posted: Tue Sep 11, 2012 11:44 pm
by xenic
After years of following the rules and using ParsePattern(), I decided to print the results in a test program. It doesn't appear to do anything! The explanation in the autodocs led me to believe that it produced some special "tokens" to be used for pattern matching functions. It just returns the exact same pattern string that is input. Is there any point in using ParsePattern() at all?

Re: Does AmigaDOS ParsePattern() do anything?

Posted: Wed Sep 12, 2012 1:41 am
by colinw
Yes, it does something, five very important things.

Firstly, it provides the API compatibility for 68K software from OS3 and before that previously
used some special high-ascii characters to "tokenise" patterns for the old 68K pattern matcher.
Secondly, for OS4, it provides the API for automatic wildcard expansion for the new pattern matcher.
Thirdly, it allows us to check whether callers are supplying the propper sized parameters, specifically
the required buffer sizes needed for handling the expansion and parsing of the patterns.
Fourthly, it provides a case/nocase matching choice.
Fifthly, it provides the ability to simply test if a string has a pattern in it.

Re: Does AmigaDOS ParsePattern() do anything?

Posted: Wed Sep 12, 2012 2:22 am
by xenic
colinw wrote:Yes, it does something, five very important things.
Firstly, it provides the API compatibility for 68K software from OS3 and before that previously
used some special high-ascii characters to "tokenise" patterns for the old 68K pattern matcher.
Secondly, for OS4, it provides the API for automatic wildcard expansion for the new pattern matcher.
Thirdly, it allows us to check whether callers are supplying the propper sized parameters, specifically
the required buffer sizes needed for handling the expansion and parsing of the patterns.
Fourthly, it provides a case/nocase matching choice.
Fifthly, it provides the ability to simply test if a string has a pattern in it.
In the case of OS4 the reference to tokenization is a little misleading then. An explanation like the one you just gave might make more sense in the OS4 AutoDocs. I've been working on Dopus4 to remove more of the deprecated AmigaDOS commands and fix some bugs. I was actually looking for a way to filter filenames and escape any wildcard characters contained in the names. I thought I might be able to use ParsePattern() and was printing out the parsed names to see how it tokenizes wildcard patterns. When I could not get it to parse any pattern into anything but the original input pattern, I started to think it was a useless outdated function. Can you give me an example of a wildcard pattern that is expanded into something different from the input pattern?