|
Post by Stefan on Jul 17, 2021 15:52:05 GMT -5
Hi Guys,
No idea if this is easy or hard to implement, but I'd love to have the ability to execute nominated Macro(s) whilst a line command is pending. Some Primary commands already allow this. Typically, these commands reposition the screen in some way.
Typical example: I can type the 'M' line command in one part of the file, and then reposition to another part of the file using UP/DOWN, FIND or LOCATE, etc before entering the 'A' line command. But I can't use a Macro to reposition the screen even if it effectively only executes a FIND or LOCATE command.
I understand that things could get ugly depending on what the macro does and the macro has neither the means to determine if a line command sequence is pending nor ability to process/use that information. I think that's OK, as the macro is only concerned with "programmatically" jumping to another part of the file, which might entail obtaining some info from/about the file to inform the FIND/LOCATE command to be issued.
I'm thinking of some kind of SET command or OPTIONS field to specify the macro name(s) to be added to the 'white list' of commands allowed to execute while a line command is pending.
What do you think? Doable?
|
|
|
Post by George on Jul 18, 2021 10:23:12 GMT -5
Stefan: Send me the macro and it's usage so I can see just what's happening. This is a hairy area and reading code written many years ago is just not doing it for me as far as 'seeing' the problem. George [UPDATE] Tried this out with my own macro. I think it will be OK. It needs a SET PENDING.MacName = Y to be set up for each macro that wants this feature. As well, in order to make the "Pending Line Command" message be visible, the macro must re-issue it via the HALT. See sample macro below. George P.S. I'll post a test version here shortly. SPFLite25.exe (512 KB) [\UPDATE] ' TRY4.macro dim msg as string spf_cmd("find fred last") ' Whatever the search is msg = Get_Msg$ ' Needed to get the Pending Line Command msg displayed halt(0, msg) '
|
|
|
Post by Stefan on Jul 18, 2021 17:26:11 GMT -5
Hi George,
Thanks for this.
I tried the SPFLite25.EXE version above with a SET PENDING.LP = Y command and it works for your simple macro, but still misbehaves with my macro. So I guess the issue is that either with the complexity of my macro, or the fact that mine doesn't re-issue the PENDING message when it stops/HALTs
I'll have to do some testing, but I'm about to go on a short holiday tmrw so it will have to wait until my return.
The user case is...
I'm working on a file and wish to MOVE or COPY a line or two from one part of the file to another. I do know the name of the FUNCTION where it needs to go but I don't know exactly where that is (above or below where I'm working). I enter the following... (1) Type MM...MM line commands to select the lines in questions (2) Type FIND "FUNCTION <name-here>(" FIRST as a primary command (3) Hit <ENTER> The screen repositions to the requested function and I... (4) Enter the A line command on the appropriate line
(5) Press <ENTER> to complete the move.
Now my LP macro effectively takes the place of the FIND command in step (2). It is preferable because I do not need to enter the full function name.
So we get the following dialog (1) Type MM...MM line commands to select the lines in questions (2) Type LP <nam> as a primary command (3) Hit <ENTER>
The screen repositions to the requested function BUT, crucially, the MM...MM line command is lost. If I now enter the A line command as above, SPFLite has no matching line commands and thus the move does not occur
By The Way...
The SPFLITE25.EXE version posted above does not treat the AUTO-colorisation files the same as previous versions. I just replaced the SPFLite2.EXE program in "C:\Program Files..blah blah" with the above version and AUTO colorisation is different to usual. My Macro.AUTO file defines a series of comment lines, e.g.
QUOTED 7 NUMERIC 7 ; COMMENT1 1 '# 0 COMMENT2 4 ' 1 COMMENT3 11 ' 0
Comments 1,2 and 3 are no longer honoured. They are overruled by the QUOTED definition.
Moving the QUOTED line AFTER the COMMENT lines does not help. The QUOTED definition trumps the COMMENT definitions.
|
|
|
Post by George on Jul 19, 2021 7:54:16 GMT -5
Stefan: I didn't try a pending block, I'll do that and see.
Re the comments, probably sent you a version that had some temp code in it related to a problem Robert reported, ignore it for now.
George
|
|
|
Post by George on Jul 19, 2021 8:03:06 GMT -5
Stefan: I tried using a pending MM/MM pair and it seens fine. Send me your macro.
George
|
|
|
Post by Stefan on Jul 23, 2021 15:37:02 GMT -5
Hi George,
This is my LP ( List Procedures) macro. LP.macro (31.98 KB)
A quick history of how I got here....
Taking a thinBasic macro source example... The idea is that I can type in LP abc and it will jump to the FUNCTION, SUB, etc whose name beings with 'abc' (in this case). It finds the FUNCTION, SUB, ::METHOD, ::ROUTINE, etc entries using a regular expression search and to allows a RFIND to subsequently 'step' through the file. A second use case is that I type in just LP and the macro excludes all lines except the FUNCTION/SUB headers. A third use case is that I can exclude all lines (possibly via use case 2) and the make specific functions 'pop-out' by specifying LP abc ; LP def ALL, etc and have just those functions' 'bodies' displayed in their entirety.
I then realised the I quite often need some code segment from a particular procedure in another place.
I would type LP ABC to get to where I know I used the desired code and enter CC...CC , then LP DEF to get back to where I want the code placed and enter A to complete the line copy. But that doesn't work because the pending line command gets lost.
So I added the SUB AddLab part to the LP.MACRO to label all the function lines it finds, so I can use LOCATE .DEF. instead to get back to the copy-target place in the file.
(Yes, I know I could just CUT/PASTE the lines I wish to duplicate elsewhere and with keyboard mapping could do that via a single keystroke, but that doesn't feel natural to me and wouldn't work for anything other than Copy or Move.)
At present, the code works fine for REXX and BASIC, except it doesn't yet support METHODs etc in BASIC and I have no way to label METHODs in REXX given that their names can be re-used in different ::CLASSes. I know I could use Tags (ie. :XXX) rather than Labels (.XXX.) which allow duplicates but ':' is an awkward character to type, given it requires a SHIFT key.
If SPFLite could be persuaded that a macro like LP (and all SPF_CMD(xxx) it issues) didn't affect the pending line commands (just like LOCATE or UP/DOWN, etc don't), the line labels wouldn't be necessary at all.
Anyway, you asked for the macro. I apologise it's such a complex beast. Don't worry about the logic per se, it is still work in progress. It would just be nice if the SET PENDING.LP = Y would simply ignore everything the macro does as if it were a single command like LOCATE, and leave the pending line command active.
|
|
|
Post by George on Jul 24, 2021 9:37:32 GMT -5
Stefan: I understand better now.
Macros are actually run under control of the Primary Command MACRO. i.e. when you say LP xxx, it is treated as MACRO LP xxx. And LP is simply an operand of the MACRO command.
So when the SPF_Cmd is performed, it basically injects the command back into the command processor. And that's where every command SPF_Cmd issues gets tested to see if it is allowable to permit scrolling, whether to reset pending, etc.
I'll have a look at whether I can propagate the SET PENDING.LP = Y to all lower level activity, but don't hold your breath, this is a tough area. We have the command MACRO creating a thread which calls thinBasic, which ends un via SPF_CMD calling the same command processor under which its still running in a different thread.
All of which of course is still running under the KB processor that handles the (Enter) key you pressed after entering LP.
George
|
|
|
Post by George on Jul 24, 2021 10:12:38 GMT -5
Stefan: Seems like the change I made for SET PENDING.LP = Y does seem to work OK. --- If the conditions are right.
Here's the test Macro I used, it only does a simple FIND for a word that I know exists throughout the file. You have to make sure to position the CSR before exiting the macro.
Example: Place MM/MM on first couple of lines Enter TRY4 - it positions to the first 'Fred' and issues the Pending message Restriction: If you go back to the Command line and Issue TRY4 again, you're back to the first found location because the cursor was on the Command line, that becomes the start search position. If TRY4 is issued via a PFK set to TRY4, it will 'walk' from one 'Fred' to the next properly.
Not knowing all the wrinkles in your LP macro, I'm not suire if this helps, but it's as far as I can make it go.
George
' TRY4.macro dim msg as string spf_cmd("find fred next") ' Replace with your search msg = Get_Msg$ ' Needed to get the Pending Line Command msg displayed Set_Csr(Get_Find_LPtr, Get_Find_col, Get_Find_Len) ' Position Csr away from Command Lins halt(0, msg) '
|
|
|
Post by Stefan on Jul 25, 2021 10:32:45 GMT -5
George, TRY4 works fine. My problem is not related to cursor positioning or using RFIND to "step" through the file. I've changed my macro, adding a dummy FIND " " at the start to trap the "Pending destination line range" message and re-display that message as you do with a HALT(0,msg$) when the macro ends. It does mean that LP can't signal failure to the user, but I could live with that.
However, the main difference between TRY4 and my modified LP macro is that after TRY4 completes, the CC..CC line command sequence survive, ie. it is still visibly there when TRY4 finishes. So when I enter the 'A' line command after TRY4 completes, SPFLite has a complete CC..CC..A sequence to work on. With the modified LP macro, the CC...CC sequence is no longer there. So when I enter the 'A' line command after LP completes, SPFLite receives only the A sequence to work on and just changes the message to "Pending source line range command".
I guess this is probably caused by LP issuing a variety of SPF_CMD(..) calls before it finishes it's job.
So it seems as though the SET PENDING<macname> = Y is only helpful for simple macros.
UPDATE: a) I don't actually need a dummy FIND command, a simple call to Get_Msg$ will yield the message. b) I'll modify LP again to see if I can 'eat' the pending line commands via GET_DEST... and GET_SRC... calls and maybe re-instate them with SPF_CMD("LINE...) before the macro ends. \UPDATE
By the way In version 21199 and the released v21186, the CANCEL command does not work if line commands are pending.
In the previous released version 21174, when a user enters CANCEL, the file is closed even if line commands are pending.
|
|
|
Post by George on Jul 25, 2021 13:04:21 GMT -5
Stefan: CANCEL has been corrected. It's a mystery, looking at the code it has been wrong for quite a while, just plain bad.
George
|
|
|
Post by George on Jul 26, 2021 10:58:02 GMT -5
Stefan: While playing with your LC macro, don't overlook the usefulness of the ~w substitution code, which is replaced by the 'word' the cursor is sitting on when Enter (or any PFK) is pressed.
E.g. I've always had the MMB set to FIND FIRST WORD ~w and the RMB set to FIND NEXT WORD ~w. I find them really handy. And don't forget mouse buttons can also have variations combined with Ctrl, Alt, Shift.
I'm sure you could take advantage of ~w to pass operands to your LC command via some PFK's.
George
|
|
|
Post by Stefan on Jul 27, 2021 10:13:12 GMT -5
George, Thanks for that. I wasn't aware of ~w so will read up on that. I am kinda 'old school', preferring to enter commands rather than relying on keystroke combinations to do stuff. I have customised the keyboard, but there's a limit to how many key-combinations I can remember reliably(!) these days :-(
Quick tangent... Regarding CANCEL not working when line commands are pending, the same is true of RELOAD and END. Neither works if line commands are pending. But you may already have tackled that when you tackled CANCEL.
Good news on the Macro front (I think, still testing bits)
It seems to work perfectly - ie. I can use the LP (Locate Procedure) macro to jump around the file even when line commands are pending and then complete the pending sequence after LP.MACRO finishes.
In case you're wondering, I changed the LP.MACRO code so that it ingests any pending line commands, does it's usual thing and then replaces the line commands on the same lines where it found them. The 'capture' logic at the beginning of LP is: '--------------------------------------------------------------------------------------- ' Capture data for any pending line commands ' Line handles are used because line pointers/numbers may change during macro execution '--------------------------------------------------------------------------------------- srcCmd$ = Get_Src_LCmd$ IF srcCmd$ <> "" THEN ' If there's a SOURCE line command src1Hnd$ = Get_Handle$(Get_Src1_LPtr) ' capture the line range src2Hnd$ = Get_Handle$(Get_Src2_LPtr) END IF dstCmd$ = Get_Dest_LCmd$ IF dstCmd$ <> "" THEN ' If there's a DESTINATION line command dst1Hnd$ = Get_Handle$(Get_Dest1_LPtr) ' capture the line range dst2Hnd$ = Get_Handle$(Get_Dest2_LPtr)
END IF
Because the macro can exit from multiple places, I changed the usual HALT(...) commands to HALT_LP(...) function calls. That way I can replace the missing line commands, clean up the line handles and resurface the 'Line command pending' message after the macro ends. '----------------------------------------------------------------------------------------- FUNCTION Halt_LP(lpRC AS NUMBER, lpMsg$ AS STRING) AS STRING '----------------------------------------------------------------------------------------- ' Restore line commands (if any) that were pending when macro started ' HALT execution with given Return code and message ' Resurface 'Line command pending' message if there was one '----------------------------------------------------------------------------------------- DIM AS STRING temp$ '--------------------------------------------------------------------------------------- ' Restore any pending line commands before stopping '--------------------------------------------------------------------------------------- IF srcCmd$+dstCmd$ <> "" THEN _
IF srcCmd$ <> "" THEN ' If there was a SOURCE line command SPF_Cmd("LINE "+srcCmd$+" "+src1Hnd$) ' place it on the source lines SPF_Cmd("LINE "+srcCmd$+" "+src2Hnd$) temp$ = Drop_Handle$(src1Hnd$) temp$ = Drop_Handle$(src2Hnd$)
END IF IF dstCmd$ <> "" THEN ' If therewas a DESTINATION line command SPF_Cmd("LINE "+dstCmd$+" "+dst1Hnd$) ' place it on the source lines SPF_Cmd("LINE "+dstCmd$+" "+dst2Hnd$) temp$ = Drop_Handle$(dst1Hnd$) temp$ = Drop_Handle$(dst2Hnd$) END IF SPF_Post_DO("(Enter)") ' Surface 'Line cmd pending' msg
END IF
Halt(lpRC,lpMsg$) END FUNCTION
I have to hand it to you. You really have designed an awesome, flexible and capable product. Bravo that man!
|
|
|
Post by George on Jul 27, 2021 10:31:27 GMT -5
Thanks for the Bravo. Many of the concepts are Roberts, he's the idea man. I just get to do most of the "now make it work" stuff.
It's nice to see someone pushing the envelope with the macro support. I'm still a bit dumbfounded at how quick they are knowing the internals as I do. PC's today, even older ones, are still screamingly fast. I remember when my first 80386 16MHZ system arrived, thought it was unbeatable. Ha!
George
|
|
|
Post by George on Jul 28, 2021 9:16:20 GMT -5
Added RELOAD and END to the list of commands allowed to proceed when there are pending line commands.
George
|
|