|
Post by Stefan on Feb 3, 2023 10:51:48 GMT -5
George,
I'm running v23030 beta
Take this example:
=WORD> A-Z a-z 0-9 _ ! ? 000001 PARSE ARG S_T_M, noQt
Place cursor on the "ARG" string Issue FIND P'@' and then press RFIND several times. Given that the profile WORD string includes the underscore '_', this should also be found, but it isn't. The cursor jumps from the S to the T to the M within the "S_T_M" string. This effectively means the Get_Curr_Word$ doesn't work either, so cursor selection is broken.
I thought you recently fixed this for another version. Could be something was lost between versions.
|
|
|
Post by George on Feb 3, 2023 11:26:35 GMT -5
Yes, broken (again). I'd use a source code manager, but frankly every one I look at seems to take so much hand-holding and management it seems I'd spend more time managing than coding. If anyone has suggestions for one that isn't that way, please speak up.
George
|
|
|
Post by Robert on Feb 3, 2023 11:53:59 GMT -5
Not a bug. P'@' should find underscore? NO. Get_Curr_Word$ doesn't work? Wrong again.
Advice (not that you will listen):
1. You should test macro functions first before declaring they are broken. Like this (a macro that works):
' Get_Curr_Word.MACRO dim str_var as string str_var = Get_Curr_Word$ HALT("curr word", "'" + str_var + "'")
2. Read the manual. Read my words on the subject.
Working with SPFLite -> Finding and changing data -> Delimiters used to determine Word, Prefix and Suffix boundaries
If you are the one looking for a string, and you consider it to be a "word", how could SPFLite not treat it as a word and find it? For example, if you were looking for a word ABCD, and you said FIND ABCD WORD, it seems pretty straight-forward that if ABCD exists as a word, it would get found. However, what if you were looking for any four-character word? If the word only had English letters, you could be pretty certain you'd find it with FIND P'@@@@' WORD.
But suppose it were a four-character string that might have an underscore or dash in it; what then? Just saying FIND P'====' WORD won't work, because you would find any four characters, as long as there were delimiters next to it, and that's not what you wanted. The data you found could be well-delimited junk. How do you solve this problem, and only find what you really want - and nothing else?
First, you modify the WORD lines so that your set of valid WORD characters is correct. That "expands" the definition of a "word character" and removes those characters as delimiters. For example, if you add the underscore to the WORD characters, then it will no longer be considered as a character that delimits a word.
Then, how can you tell SPFLite to only look for the characters that you say are part of a special kind of "word" that you want? We could have changed how the @ picture works, but it's best not to tamper with that, so @ stays as-is, and only matches letters. Instead, SPFLite defines two extended picture code types:
& defines any character in in the set of WORD characters
% defines any character not in the set of WORD characters
So, if you want a four-character string of your kind of words, as defined by your settings of the WORD string, you would do this:
FIND P'&&&&' WORD
This works because WORD means a string delimited by non-WORD characters or the edges of a line, and the & picture means all characters which are in in the WORD character list.
What is nice about this is that the WORD characters are in the PROFILE, so whether you have ordinary text, C programs, COBOL programs, or some special-purpose data, you can customize each file type to exactly the definition of what a "word" means to best suits your needs.
|
|
|
Post by George on Feb 3, 2023 12:28:45 GMT -5
Robert: Thanks. I started looking at this and could not spot any 'missing' code from the previous fix. I did not spot the invalid use case either.
Subtle, but important distinction in the Picture characters.
George
|
|
|
Post by Stefan on Feb 4, 2023 4:51:15 GMT -5
Robert, Thanks for the tip. A simple "use P'&' instead of P'@'" would have sufficed.
No need for the lecture.
|
|