# poke command

The poke BASIC program sends either a string of characters, or one or
 more TCL commands to the input buffer of another port.

## Syntax

```

 poke port.number{,{text}}
 poke port.number{}esc{file.reference {item-ID}}
 poke port.number esc
 poke port.number tcl.commands esc{tcl.commands{esc}...}
```

## Parameter(s)

| port.number | Designates the target port number. |
| --- | --- |
| text | Contains any characters, except segment marks (x'ff'), and can be unlimited in length. The text can be preceded by a space, which optional. When the text is omitted, a carriage return is sent to the target port. The text string can be enclosed in single or double quotation marks, or backslashes. |

## Description

One or more TCL commands can be sent directly to the target port. Each TCL command must be
 followed by an escape, which is treated as a carriage return on the receiving port.

An item containing one or more valid TCL commands can also be transmitted directly from a file.
 The transmitted item must contain one valid TCL command on each attribute. This feature is
 accomplished by poking an escape to the target port. The process prompts for the file name and
 item-ID of the item to transmit and execute.

The poke command displays the number of characters it has successfully
poked to the target port’s input buffer. The number reported may not
match the actual number of characters sent due to the condition of
the target port’s input buffer.

The ESC key is used by poke to terminate commands, a special provision applies
for transmitting an actual escape. This is accomplished by pressing
ESC twice. A set of two escapes is treated (and poked) as one escape.

CAUTION:
 This process does *not* check to see that the target port is ready to accept characters.
 In other words, if the target port is in the Update Processor or a FlashBASIC program at an
 input statement and the (TCL) who command is poked to
 the target port, it is treated as data on the receiving end. Some functions of the Update
 processor/TCL command stack interfere with transmission of control characters from the TCL
 prompt.

 For example, suppose there was a need to poke a CTRL+D to another port.
 The TCL command stacker uses CTRL+D to retrieve the previous command. The only way this could
 be accomplished from TCL is to first turn off the command stacker for the current port with the
 stack-off command. Then the CTRL+D could be poked. The
 stack-on command restarts the stacker. For this reason, it is probably
 easier to do all poking from FlashBASIC, where control characters can be poked by their
 char equivalents.

## Example(s)

**Example 1**

The following example sends a carriage return to port 16.

```
 poke 16
 [1028] 1 characters poked.
```

 **Example 2**

The following example sends a carriage return to port 16.

```
 poke 16,
 [1028] 1 characters poked.
```

 **Example 3**

The following example sends the string, "answer the phone!", to port 16, without following the
 (poked) string with a carriage return.

```
 poke 16,answer the phone!
 [1028] 17 characters poked.
```

 **Example 4**

The following example is exactly the same as **Example 3**.

 Single or double quotation marks and backslashes have no effect on the string being sent,
 unless the string begins with, but not followed by, a literal quotation mark.

```
 poke 16,"answer the phone!"
 [1028] 17 characters poked.
```

 **Example 5**

The following example fails because the string is preceded by a quotation mark.

```
 poke 16 "hi
 [2] Uneven number of delimiters (’ " \).
```

 **Example 6**

The next example shows that a trailing quotation mark
is accepted.

```
 poke 16 hi"
 [1028] 3 characters poked.
```

 **Example 7**

The following example shows that embedded quotation marks are permitted.

```
 poke 16,don’t panic!
 [1028] 12 characters poked.
```
In all of the previous examples, no carriage return was
entered at the end of the poked strings.

 **Example 8**

In this form of a poke, the string being sent is an actual TCL command. The
 `[` is echoed by pressing **Esc**. This pokes a who to
 port 16 and issues a carriage return to process the command.

```
 poke 16 who[
```

 **Example 9**

The following example pokes the who, time, and
 ovf commands to port 16 and executes them.

```
 poke 16 who[time[ovf
```

 **Example 10**

The following example uses the port number, followed by pressing **Esc**, and then
 **Enter**. The process prompts for the file name and item-ID of the item to transmit.

```
 poke 16[
 poke from file-name item-name:md script1
```

 **Example 11**

Each attribute of the specified item, starting at the first attribute, is treated as a valid TCL
 command.

 For example, `script1` could look like this:

```
 id: script1
 att 1: who
 att 2: time
 att 3: ovf
```

 **Example 12**

The file name in this example is supplied on the command
line. The process only prompts for the item-ID of the item to transmit.

```
 poke 16[md
 poke from item-name:script1
```

 **Example 13**

The file name in this example and item-ID are specified
on the command line.

```
 poke 16[md script1
 [1028] 13 characters poked.
```

 **Example 14**

In this form, an item is constructed spontaneously , then poked into
 the target port’s input buffer. This example executes the who,
 time, and ovf commands on port 16.

```
 poke 16[
 poke from file-name item-name:[
 0001 :who
 0002 :time
 0003 :ovf
 0004
 [1028] 13 characters poked.
```

 **Example 15**

The following example pokes two Esc key results in one escape being sent.

```
 poke 16 [[
 [1028] 1 characters poked.
```

 **Example 16**

The following example illustrates using execute to poke
 characters to another port. This instruction pokes a CTRL+X, then a CTRL+E, followed by a
 literal `"y"`. This explicitly exits the receiving port from the current item in
 the Update processor.

```
 execute "poke 16 " : char(24):char(5):"y"
```

## See also

- [tcl command](https://d3codex.com/tcl/tcl-command/)
- [tcls command](https://d3codex.com/tcl/tcls-command/)

---
Source: https://d3codex.com/tcl/poke-command/ - part of the D3Codex reference.
