Capture Playback and Convert.Keystrokes

Published ByDateVersionKnowledge LevelKeywords
Sprezzatura Ltd01 APR 19933.03+EXPERTCAPTURE, @PLAYBACK, CONVERT.KEYSTROKES

Way back in Volume 1 we showed how @Playback could be loaded with a capture script for instant replay of captures. Recently a number of people have reported a problem with capture scripts, namely that embedded code and commands no longer work as they ought. For example, the script

     WINDOW {SPACE} DEMO {CR}
     @HLP Here we are in the demo window@
     1234 {CR}

ought to invoke the Demo window (if run from TCL), pause and display a help message, then after a key was pressed, continue on and enter 1234 into the key field. What in fact happens is that this script fails to run.

Examination of CONVERT.KEYSTROKES, the routine responsible for converting text to and from internal form (scan codes, escape sequences et al) to external form ({F1}, {ALT-8} et al) identifies this problem.

CONVERT.KEYSTROKES takes four parameters as follows :-

StringThe string to be converted to or from internal form
Action"W" for convert to, "K" for convert from
UnknownDoes not seem to be used
FlagReturns result of operation, 1 for failed, 0 for OK

The string to be converted is both passed and returned in the first parameter. If the conversion is successful, a string is returned suitable for placing directly into @PLAYBACK. If the conversion fails, the string is unchanged and Flag is set to 1.

Thus for the above script we would establish the call

  STUFF    = "WINDOW {SPACE} DEMO {CR} "
  STUFF<-1>= "@HLP HELLO@"
  STUFF<-1>= "1234 {CR}"
  CALL CONVERT.KEYSTROKES(STUFF, "K", "", FLAG)

However, this call fails to convert and returns a Flag of 1. Removing the "LP" from the "HLP" causes the conversion to work. Further examination reveals that any Catalyst code of more than one character now causes the conversion to fail, hence the failure of an HLP. The good news is that catalyst calls of only one character still function, so until this problem is resolved it can be worked around by using the following subroutine, which simply takes a branch and treats it as a code and command.

  Subroutine Replay(Branch)
    SavePlay = @Playback
    @Playback = ""
    Code = Branch[1, "*"]
    Command = Branch[-1, "B*"]
    Call Catalyst(Code, Command)
    @Playback = SavePlay
  Return

Then our script would become

     WINDOW {SPACE} DEMO {CR}
     @S REPLAY,HLP*Here we are in the demo window@
     1234 {CR}

Note though that the * delimiter will need to be changed if you wish to do B catalyst calls etc.

(Volume 4, Issue 10, Pages 4,5)

  • tips/revmedia/v4i10a1.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1