2

This is an extract of a file from this project (full text here):

Method redirects() [ Private, ProcedureBlock = 0 ]
{
/// Mnemonics
APC d APC^%X364 q
BEL d BEL^%X364 q
CBT(%1) d CBT^%X364(%1) q
CCH d CCH^%X364 q
CHA(%1) d CHA^%X364(%1) q
CHT(%1) d CHT^%X364(%1) q
CNL(%1) d CNL^%X364(%1) q
CPL(%1) d CPL^%X364(%1) q
CPR d CPR^%X364 q
CTC(%1,%2,%3,%4,%5,%6,%7,%8,%9) d CTC^%X364(%1,%2,%3,%4,%5,%6,%7,%8,%9) q
CUB(%1) d CUB^%X364(%1) q
CUD(%1) d CUD^%X364(%1) q
CUF(%1) d CUF^%X364(%1) q
CUP(%2,%1) d CUP^%X364(%2,%1) q
CUU(%1) d CUU^%X364(%1) q
CVT(%1) d CVT^%X364(%1) q
DA d DA^%X364 q
DAQ(%1,%2,%3,%4,%5,%6,%7,%8,%9) d DAQ^%X364(%1,%2,%3,%4,%5,%6,%7,%8,%9) q
DCH(%1) d DCH^%X364(%1) q
DCS d DCS^%X364 q
DL(%1) d DL^%X364(%1) q
DMI d DMI^%X364 q
DSR(%1) d DSR^%X364(%1) q
EA(%1) d EA^%X364(%1) q
ECH(%1) d ECH^%X364(%1) q
ED(%1) d ED^%X364(%1) q
EF(%1) d EF^%X364(%1) q
EL(%1) d EL^%X364(%1) q
EMI d EMI^%X364 q
EPA d EPA^%X364 q
ESA d ESA^%X364 q
FNT d DNT^%X364 q
GSM d GSM^%X364 q
GSS d GSS^%X364 q
HPA(%1) d HPA^%X364(%1) q
HPR(%1) d HPR^%X364(%1) q
HTJ d HTJ^%X364 q
HTS d HTS^%X364 q
HVP(%1,%2) d HVP^%X364(%1,%2) q
ICH(%1) d ICH^%X364(%1) q
IL(%1) d IL^%X364(%1) q
IND d IND^%X364 q
// And others, followed by old style MAC routines
}

This is the first time I see that... And I can't find documentation on what those "mnemonics" are.

What are they? Where is the documentation for it?

fge
  • 119,121
  • 33
  • 254
  • 329
  • http://docs.intersystems.com/cache20152/csp/docbook/DocBook.UI.Page.cls?KEY=GIOD_intro#GIOD_intro_definemnemomic Here Nikita @zitro intercepts standard mnemonics inside of his own routine. – tsafin Feb 20 '16 at 22:11
  • @tsafin uhm, OK, but does it mean it can be defined anywhere in an ObjectScript method? Also, are `d` and `q` the Do and Quit command respectively, or something else? – fge Feb 21 '16 at 01:02
  • Yes and yes again. Here's simple redirect example https://github.com/intersystems-ru/Cache-MDX2JSON/blob/master/MDX2JSON/AbstractREST.cls.xml#L457 – rfg Feb 21 '16 at 07:48
  • Commands have long and short form (quit and q respectively) and register insensitive (QUIT, quIT etc) – rfg Feb 21 '16 at 07:52
  • @rfg I knew about the short forms of commands :) It is just that I have already encountered legacy routines in methods but always at the end of the method, never at the start like that. Also, while these "routines"(?) are indeed defined inside the method I don't see them used anywhere :/ – fge Feb 21 '16 at 08:59
  • @fge They are initialized as a device at https://github.com/intersystems-ru/webterminal/blob/22134e7e14c558ab6cd720f52e06c478781a63bd/export/WebTerminal/Engine.xml#L674 and then used with `do ##class(%Device).ReDirectIO()` command throughout the class. – rfg Feb 22 '16 at 12:20

1 Answers1

4

This is a standard mnemonics implementation for WebTerminal inside WebTerminal itself.

To make WebTerminal work as common terminal do over WebSockets, one of the most important things is a little line of code

use $io:(/NOXY:/BREAK):"^" _ ..InitialZName

which is executed at the beginning of WebSocket server initialization, and which actually set up the name of the mnemonic space, which is equal to WebTerminal's compiled routine name (like WebTerminal.Engine.1.int).

These mnemonics (APC, BEL, etc) are a little macro programs, which user can call from the terminal using the special syntax. For example, mnemonic "CHA" is used to set the caret position:

USER > w "Pos 0", /CHA(14), "Pos 14", /CHA(35), "Pos 35"
Pos 0        Pos 14               Pos 35

In order to make user able to access all of these with this syntax, there were a need to include all standard mnemonics names into terminal routine, which is set as a mnemonic space for each client by default (because setting the default mnemonic space, which include these mnemonics breaks WebTerminal). The only solution left is to declare them inside any method (in this case, the method named "redirects") using ProcedureBlock = 0.

Talking about the syntax, in general, we have

MNEMONICNAME(%ArgByRef) do MNEMONICNAME^%SYSTEMROUTINE(%ArgByRef) quit

This just calls all of the standard mnemonics which can be found in ^%X364 system routine.

ZitRo
  • 1,163
  • 15
  • 24