len
Freshman Member
Posts: 15
|
Post by len on Jan 15, 2014 16:08:14 GMT -5
Here is my first SPFLite macro. I quote from the macro header: ' CsrFind.MACRO ' ' Issue a FIND command with the find target defined as: ' If there is a text string selected, it becomes the find ' target, ' If nothing is selected, the word starting with the cursor ' position is the find target. A word ends with the next ' character that is not a letter, a number, '-', or '_'. ' Syntax: CsrFind ' Should be assigned to a key, I use alt-S. ' Author: len CsrFind.macro (2.3 KB)
|
|
|
Post by George on Jan 16, 2014 11:07:41 GMT -5
Hi Len,
Nice job. One suggestion, as this is something that is only too easy to have overlooked, rather than hard coding the letters making up a word, you can ask for the list associated with the current Profile using the Get_Profile$ function.
e.g. your line:
Dim WordChars As String Value "abcdefghijklmnopqrstuvwxyzåäöABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ0123456789-_"
could be done as:
Dim WordChars As String Value Get_Profile$("WORD")
George
|
|
len
Freshman Member
Posts: 15
|
Post by len on Jan 16, 2014 13:25:14 GMT -5
George, Thanks for your nice words and the tip. I implemented it right away. As I wanted to include a few special characters from my native tongue and - and _ that are frequent in variable names I changed it to read: Get_Profile$("WORD") & "åäöÅÄÖ-_". A citizen of another country would probably want another set of extra characters.
By the way, now I came to think of another feature that would be nice to implement in the macro: Would it be possible to have the FIND command end up in the list of commands that can be retrieved by the RETRIEVE command. Sometimes the string that you put the cursor on is not exactly the one you want to search for. You might want to change a few characters and do a new search or just do the same search a minute later when you don't have the original string in front of you on the screen. I don´t mean that I want the FIND command to end up in the retrieve list as an alternative to issuing the FIND, only that it would be nice if it could be retrieved after the FIND has been issued.
I have written a macro with the same logic in my 3270 emulator. There the FIND command gets placed in the retrieve list, but that is natural because the emulator is external to the ISPF editor and really puts the FIND command in the editor command line and presses Enter.
/ len
|
|
|
Post by George on Jan 16, 2014 14:54:25 GMT -5
Len: You should also look at the option to include international characters under Options -> General -> Include international characters for WORD/Alphabetic Pictures? It may of course add too many since it includes basically all the ASCII European characters.
As to adding a command to the RETRIEVE stack. I'd be very leery of that. For your macro, it would not be a problem. But think of a macro that is looping through the whole file by doing successive FIND commands. The stack would be full of FIND commands.
George
|
|
len
Freshman Member
Posts: 15
|
Post by len on Jan 16, 2014 15:51:23 GMT -5
George, I keep being amazed by all the features you have included in SPFLite. I will change my macro once more and remove my national characters. I changed to "Include international characters" and performed the "erase Normal characters for P'.' picture literals" trick, as I had earlier modified that string to include my national characters".
The fact that there are a lot of irrelevant international characters in the string does not matter since those characters are not present in the strings that I am interested in handling. Marvelous!
Another wild idea for the retrieve issue, if you would be interested: What about making the inclusion of SPF_Cmd commands in the retrieve stack optional by prefixing the command string with &. In my mind that would make some sense, since & normally means "retain the command on the command line". The meaning in macros would then be "retain the command in the retrieve stack". The command would be saved in the retrieve stack without the &. Then it is of course another matter if this is at all doable and if there are drawbacks that I don´t see.
/ len
|
|
|
Post by George on Jan 17, 2014 10:26:35 GMT -5
Len: Your suggestion of using the & should be fine, right now I can't think of anything internally that would prevent it. I'll create a ToDo so we don't forget it.
George
|
|
|
Post by George on Jan 17, 2014 15:21:32 GMT -5
If you don't like END, maybe you should set the minimum command length for Retrieve to 4 or higher. The purpose of the setting is exactly that, don't retain commands that are just as quick and easy to re-type. If you did so, commands of length 3 and under would not be retrievable, not exactly a big loss.
George
|
|