Post by Stefan on Sept 26, 2024 11:03:00 GMT -5
George, Robert
MACROMODE Specification
MACROMODE allows you to specify how a macro is to be treated during processing. i.e. Either as a SINGLE line command, or as a BLOCK mode command.
Like the difference between a C line command, and a CC line command.
SET MACROMODE.macroname = BLOCK | SINGLE
In short, we could use a description which better explains:
Part-2
There are two separate descriptions a few lines apart for the PENDING specification.
Macro Pending
This type of SET statement allows you to flag a particular Macro name as one which should be allowed to generate a "Pending Line Command" message.
Normally, Macros would not be allowed to do this. To activate this for a specific macro name enter
SET PENDING.macroname = Y
PENDING Specification
PENDING allows you to indicate whether a macro is capable of handling other pending line commands or not.
SET PENDING.macroname = Y | N
Although I have used this feature, neither description is terribly precise.
What exactly is PENDING = Y supposed to enable the macro to do?
The first suggests that it allows a macro to programmatically place line commands, (say CC...CC) on data lines which persist (are left 'pending'), to be 'completed' by the user, after the macro has ended (e.g. user adds 'A', etc).
The second suggests that SPFLite will allow the macro to execute, even if line commands (say CC...CC) are 'pending', i.e the macro can process (or ignore) these commands for its own functional purpose.
At this point Copy operation completes
Part-1
One of you probably remembers adding this, and I'm certain it has its uses, but I do not understand/remember it.
MACROMODE Specification
MACROMODE allows you to specify how a macro is to be treated during processing. i.e. Either as a SINGLE line command, or as a BLOCK mode command.
Like the difference between a C line command, and a CC line command.
SET MACROMODE.macroname = BLOCK | SINGLE
Question:
- Is this in some way related to the SET TRACK feature, per chance?
Comments:
- The phrase "... how a macro is to be treated..." is incorrect. The setting is not specific. It should be "... how all macros are to be treated...".
- Does the phrase "...SINGLE line command..." mean this applies specifically to line-command macros or does it also apply to primary macro commands?
- The comparsion to the "...C/CC commands..." is misleading and confusing.
Does that mean that BLOCK mode is the default mode, as in "The collection of all the commands issued by the macro is treated as a ONE (deliberately avoiding the word 'single' here) command by SPFlite"
Or is it in fact the other way around?
What would happen differently if a user switches from one mode to the other?
- What's the difference between BLOCK and SINGLE?
- What's the default if neither is specified?
- Why would one change from one mode to the other?
Part-2
There are two separate descriptions a few lines apart for the PENDING specification.
The first says...
This type of SET statement allows you to flag a particular Macro name as one which should be allowed to generate a "Pending Line Command" message.
Normally, Macros would not be allowed to do this. To activate this for a specific macro name enter
SET PENDING.macroname = Y
The second says...
PENDING allows you to indicate whether a macro is capable of handling other pending line commands or not.
SET PENDING.macroname = Y | N
Although I have used this feature, neither description is terribly precise.
What exactly is PENDING = Y supposed to enable the macro to do?
The first suggests that it allows a macro to programmatically place line commands, (say CC...CC) on data lines which persist (are left 'pending'), to be 'completed' by the user, after the macro has ended (e.g. user adds 'A', etc).
The second suggests that SPFLite will allow the macro to execute, even if line commands (say CC...CC) are 'pending', i.e the macro can process (or ignore) these commands for its own functional purpose.
In fact, SET PENDING.macroname = Y enables both these use cases.
There is a common third use case:
(1) user enters a 'C' line command to copy one line(2) user issues a primary command (e.g LOCATE, FIND, etc) to reach another part of the file
At this point the 'C' line command persists
(3) user enters an 'A' line command on another line to complete the line copy operation.At this point Copy operation completes
This works because the built-in commands do not interfere with the line commands at all.
However, SET PENDING.macroname = Y provides no support if the primary command in step(2) is a macro rather than a built-in command.
If you replace the built-in command in step(2) with a macro (e.g. LP), the line commands entered before the macro started do not persists after the macro finishes.If the user wishes pre-macro line command to persist after the macro has ended, the macro code must:
- capture the line commands present at the start of the macro (Move/Copy/After/Before/etc)
- reliably label which line/lines(s) are affected
- perform whatever the function of the macro is
- re-apply those line commands on the correct original lines
- remove the labelling from the affected lines
I think the two PENDING entries should be combined and augmented to explain in greater detail, what SET PENDING = Y enables, as well as what it does not support.
The two procedures listed below will capture (Save_Environment) and replace (Restore_Environment) persistent line commands
Call Save_Environment at the start of the macro and Restore_Environment before the end.
GLOBAL AS STRING gSrcLCmd$, gDstLCmd$ = "" ' line cmds for Source and Destination
GLOBAL AS STRING gSrc1Hnd$, gSrc2Hnd$ = "" ' line Handles for SOURCE lines
GLOBAL AS STRING gDst1Hnd$, gDst2Hnd$ = "" ' line Handles for DESTINATION lines
SUB Save_Environment()
'=========================================================================================
' Capture details for any pending line commands
'
' NOTES: There are limitations. This does not reliably capture every line command.
' IF Source line command is 1-char but Src1Lptr and Src2LPtrs indicate a line
' range, the line command is converted to a block command, e.g. C5 -> CC...CC
' Uses Line handles as line pointers/numbers may change during macro execution.
'=========================================================================================
LOCAL AS STRING shr$
gSrcLCmd$ = Get_Src_LCmd$ ' SOURCE line comamnds
IF gSrcLCmd$ <> "" THEN ' If there is any
IF Get_Src1_Lptr <> Get_Src2_Lptr AND _ ' IF Lcmd format is 1 char...
Len(gSrcLCmd$) = 1 THEN _ ' ...followed by digit(s)
gSrcLCmd$ += gSrcLCmd$ ' Double up on the lcmd char
shr$ = IIF$(Has_Handle(Get_Src1_Lptr),"Y","N") ' Mark as SHARED if necessary
gSrc1Hnd$ = shr$ + Get_Handle$(Get_Src1_Lptr) ' Capture the line range
shr$ = IIF$(Has_Handle(Get_Src2_Lptr),"Y","N")
gSrc2Hnd$ = shr$ + Get_Handle$(Get_Src2_Lptr)
END IF
gDstLCmd$ = Get_Dest_LCmd$ ' DESTINATION line comamnds
IF gDstLCmd$ <> "" THEN ' If there is any
shr$ = IIF$(Has_Handle(Get_Dest1_Lptr),"Y","N") ' Mark as SHARED if necessary
gDst1Hnd$ = shr$ + Get_Handle$(Get_Dest1_Lptr) ' Capture the line range
shr$ = IIF$(Has_Handle(Get_Dest2_Lptr),"Y","N")
gDst2Hnd$ = shr$ + Get_Handle$(Get_Dest2_Lptr)
END IF
END SUB
SUB Restore_Environment()
'=========================================================================================
' Re-place previously captured line commands on the appropriate lines
'=========================================================================================
IF gSrcLCmd$ <> "" THEN ' If there were SOURCE line cmds
SPF_Cmd("LINE "+gSrcLCmd$+" "+Mid$(gSrc1Hnd$,2)) ' Re-place on relevant line(s)
IF Left$(gSrc1Hnd$,1) = "N" THEN _ ' If handle is unshared
Drop_Handle$(Mid$(gSrc1Hnd$,2)) ' Remove it from line
IF gSrc1Hnd$ <> gSrc2Hnd$ THEN
SPF_Cmd("LINE "+gSrcLCmd$+" "+Mid$(gSrc2Hnd$,2))
IF Left$(gSrc2Hnd$,1) = "N" THEN _
Drop_Handle$(Mid$(gSrc2Hnd$,2))
END IF
END IF
IF gDstLCmd$ <> "" THEN ' If there were DEST line cmds
SPF_Cmd("LINE "+gDstLCmd$+" "+Mid$(gDst1Hnd$,2)) ' Re-place on relevant line(s)
IF Left$(gDst1Hnd$,1) = "N" THEN _ ' If handle is unshared
Drop_Handle$(Mid$(gDst1Hnd$,2)) ' Remove it from line
IF gDst1Hnd$ <> gDst2Hnd$ THEN
SPF_Cmd("LINE "+gDstLCmd$+" "+Mid$(gDst2Hnd$,2))
IF Left$(gDst2Hnd$,1) = "N" THEN _
Drop_Handle$(Mid$(gDst2Hnd$,2))
END IF
END IF
END SUB