Reviewed and revised December 2023
tab(-10, AG_CLIPBOARD); opcode, srow, scol, erow, ecol, rtnflag, text; chr(127); Tab(-10,x) Syntax Notes
AG_CLIPBOARD (65) allows for copying text from a variable or screen coordinates to the clipboard, or for retrieving the contents of the clipboard.
This function has both a subroutine and a print tab implementation.
Parameters
rtnflag
Set to 1 to request a response
See MX_CLIPBOARD for descriptions of the remaining parameters.
Response
If rtnflag is not set to 1, none. Otherwise the response depends on the opcode. For opcodes 1, 3, and 5, the response is:
status,~
For opcodes 0 and 2, the response (retrieve clipboard contents) is:
status,<clipboard contents>~
Note that unlike most other AG_xxx responses, this one ends with a tilde instead of a carriage return, partly because the clipboard contents may or may not contain carriage returns. Consequently you cannot use a traditional INPUT statement to retrieve the response and must rely on a method which doesn't require a carriage return termination. See Examples.
Examples
Copy some explicit text to the ATE clipboard:
! opcode=3, coordinates=0, rtnflag=0 (no response needed)
? tab(-10,AG_CLIPBOARD);"3,0,0,0,0,0,some clipboard text";chr(127);
Retrieve ATE clipboard contents. Note that return string is formatted as 'status,text~' with no trailing <CR>, so we can't use INPUT to retrieve it. Instead we'll input it one character at a time to build up the string, then parse it into the status and text...
MAP1 PLINE$,S,512
MAP1 A,F
? tab(-10,AG_CLIPBOARD);"2,0,0,0,0,1";chr(127);
do
A = getkey(-1)
if A # 126 PLINE$ = PLINE$ + chr(A)
loop until A=126 ! terminate on tilde (126)
! now parse it out
A = instr(1,PLINE$,",")
if A > 0 then STATUS = PLINE$[1,A-1] : PLINE$ = PLINE$[A+1,-1]
? "Status: ";STATUS
? "Clipboard contents: ";PLINE$
Note that the above case could be handled much more simply with a single instance of MX_CLIPBOARD.
See Also