trap and execute C prefix command

r corak
  • r corak

    r corak - 2006-11-02

    Can I somehow grab a C or CC or M or MM command, execute my own macro, then cause THE to execute its normal version of the command?

    I can trap command line commands, like SET SYNONYM DIR MACRO DIR then in my DIR.THE issue COMMAND DIR.  Is there a way to do the analogous processing for prefix commands?

    • LesK

      LesK - 2006-12-02

      If THE has the same restriction as Xedit, then the answer is NO (iirc).

    • r corak

      r corak - 2007-03-06

      "command set prefix synonym C pfx" will trap C and shuffle it off to the PFX macro.  But handling commands that change the line's line number ain't all that easy.  For example, consider if one is trapping C and M and F.  Let's say one enters a prefix command C and a prefix command M and a prefix command F.  The C or the M gets executed (that is passed to PFX and handled by PFX), the other remains (that is, SET PENDING by PFX because it hasn't been handled yet), but its line number may have been affected by the results of the first operation.  Generally, this whole business is not for the faint of heart.

      • Mark Boonie

        Mark Boonie - 2007-03-07

        I think it's more straight-forward than it appears.  Remember that the pending list is executed every time it's changed.  This means that if your macro finds that it doesn't have all of the information it needs (for example, the user didn't specify P or A, or only specified the first of a CC block pair) then the macro simply exits without doing anything.  It gets re-executed whenever the missing information is supplied.

        This allows the macro to not care about any other pending macros, because the other macros won't be "in the middle" of anything.  For example, suppose the pending list contains C, M, and F, in that order.  When the C handler gets control, it finds everything it needs with the pending F, so it does the Copy.  By the time the M handler gets control, there's no more C or F to worry about.

        Note that the way the IBM prefix commands work is that the second prefix command of a block is the one that does the processing.  Using this model, the first time the C handler gets control to process the first CC of the pair, it checks for a *preceding* CC and then executes the copy if both the preceding CC and either an F or P exist.  If there is no preceding CC, it doesn't do the copy and allows the second invocation of the C handler to do the copy.

        - mb


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks