# crt-device command

The crt-device command forces BASIC and FlashBASIC to use the CRT
 terminal device instead of the printer device for the @ functions with the printer in the ON
 state.

## Syntax

```
 crt-device {([n\|f]}
```

## Parameter(s)

| on | If the crt-device state is ON (1378), then the terminal device is used for @ functions. |
| --- | --- |
| off | If the crt-device state is OFF (1379), then: If the Printer state is ON, then the printer device is used. If the Printer state is OFF, then the terminal device is used. |

## Description

If no option is provided, the current state is returned.

 **1378 and 1379 @ functions**

- [1378] @ functions always use the terminal device.

- [1379] @ functions use a device based on the printer state.

## Example(s)

**Example 1**

 For this example, the current state is set to use the device for @ functions based on
 the value of the BASIC printer statement:

```
 :crt-device

 [1379] @ functions use device based on printer state.
```

 This example sets up a printer device to use:

```
 :assignfq 0,hp-lzrii

 Assigned form queue device 0, HP-LZRII
```

 This example sets the form queue and uses options to show the settings:

```
 :sp-assign 0hs?

 Line# Status Copies Form# Device
 0 hs 0 0 hp-lzrii
```

 The following example shows that @(-13) is set to the ESC character, followed by an open
 parenthesis **(**, a lowercase **s**, the number **3**, and an uppercase
 **B**:

```
 :list dm,devices, hp-lzrii a19
 Page 1 dm,devices,

 dm,devices, a19..............
 hp-lzrii d,[,c&#39;(s3B&#39;,< -13 bf on

 [405] 1 items listed out of 1 items.
```

 The following example shows the terminal device for the line set to vt100:

```
 :term

 terminal name: vt100
 product name: VT100
 terminal width: 132 printer width: 80
 depth: 64 depth: 59
 lineskip: 0
 lf delay: 1
 ff delay: 1
 back space: 8
```

 The following example shows that the value is set to the ESC character, followed by an
 open square bracket **[**, the number **7**, and a lowercase **m**.

```
 :list dm,devices, vt100 a18
 Page 1 dm,devices,

 dm,devices, a18..............
 vt100 D,X&#39;1B&#39;,C&#39;[7m&#39;,< -13 BF ON

 [405] 1 items listed out of 1 items.
```

 The following example shows the test code:

- The first line uses mcp as a conversion of each character.

- The second line prints the decimal value for each character.

```
 :tstcursor
 Terminal code
 .[7m
 27 91 55 109
 Printer code
 .(s3B
 27 40 115 51 66
```

 The terminal code is **ESC [ 7 m**.

 The printer code is **ESC ( s 3 B**.

 **Example 2**

 For this example, the r83 backward compatible option is used:

```
 :crt-device (n

 [1378] @ functions always use terminal device.
```

 In this example, only the terminal device codes will be used. The printer and terminal
 codes are the same and match that of the vt100 device item.

```
 :tstcursor
 Terminal code
 .[7m
 27 91 55 109
 Printer code
 .[7m
 27 91 55 109
```

 The following example shows the test code:

```
 tstcursor
 001 printer off; * turn the printer off to force using the terminal device
 002 term_minus13 = @(-13)
 003 printer on; * turn on the printer to maybe use the printer device
 004 prt_minus13 = @(-13)
 005 *
 006 st = term_minus13
 007 crt "Terminal code "
 008 gosub showit; * go show what the terminal device codes are
 009 *
 010 st = prt_minus13
 011 crt "Printer code "
 012 gosub showit; * go show what the printer device codes are
 013 *
 014 stop
 015 *
 016 showit: *
 017 crt oconv(st,&#39;mcp&#39;); * output the string as is but no control characters
 018 l = len(st)
 019 for x = 1 to l
 020 crt seq(st[x,1]):" ": ;* show each character as it&#39;s decimal ASCII value
 021 next x
 022 crt
 023 return
```

## See also

- [printer statement](https://d3codex.com/pickbasic-flashbasic/printer-statement/)

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