Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASCII Cursor Movement Symbols 1

Status
Not open for further replies.

johndoh

Programmer
Oct 26, 2001
1
US
While debugging a program I 'ctrl-break'ed [broke?] during an input statement from the Immediate window. Afterward, running the program caused the printing of characters that normally produce cursor movement to instead print actual symbols, the ASCII table showing most of them. The character codes affected are 7,9,10,11,12,13,28,29,30,and 31.
I'm curious what's causing it and if there is another, more elegant way of getting these characters.

Example.

Code:
CLS
PRINT "A"; CHR$(31); "B"
which produces
Code:
A
 B

Now type:

input x

in the Immediate window, enter, then control-break from the output screen.

Rerunning the program now gives

A(upsideDownTriangle)B

as the ASCII chart suggests.

To get back to normal, run the input statement again without breaking.

Btw, I've found this to happen in both QB1.1 and 4.5

Thank you,
Johndoh
 
There is a simple explaination. None of the acsii characters that you posted above are screen characters.
7 is BEEP
9 is TAB
10 is LINE FEED.... and so on
 
The first 32 characters in the ASCII character set are defined to be "control" characters. They were originally designed to do things on teletype terminals (e.g. 10 is called LF == Line Feed (for the paper ^_^), 13 is called CR = Carriage Return, etc.). Many of these meanings had sensible extensions to virtual terminals on a screen. It probably makes the most sense for you to make an array with their symbolic names, and then display those instead of the characters. The following list shows the symbolic names of the first 32 ASCII characters:
[tt]
ASCII | Name | Description
------+------+---------------------------------
0 | NUL | Null (nothing)
1 | SOH | Start of Header
2 | STX | Start of Text
3 | ETX | End of Text
4 | EOT | End of Transmission
5 | ENQ | Enquiry
6 | ACK | Acknowledge
7 | BEL | Bell (PC speaker beep)
8 | BS | Backspace (not necessarily destructive)
9 | HT | Horizontal Tab
10 | LF | Line Feed (cursor down one line/page up one line)
11 | VT | Vertical Tab
12 | FF | Form Feed (move to start of next page/clear screen)
13 | CR | Carriage Return (cursor to start of line)
14 | SO | Shift Out
15 | SI | Shift In
16 | DLE | Data Link Escape (return to command mode)
17 | DC1 | -.
18 | DC2 | (_ No assigned meaning, but DC1 & DC3 are
19 | DC3 | ( often used for Xon/Xoff flow control
20 | DC4 | -'
21 | NAK | Negative Acknowledgement
22 | SYN | Synchronous Idle
23 | ETB | End of Transmission Block
24 | CAN | Cancel
25 | EM | End of Medium
26 | SUB | Substitute
27 | ESC | Escape (used for control extensions, like VT terminal emulations)
28 | FS | File Separator
29 | GS | Group Separator
30 | RS | Record Separator
31 | US | Unit Separator
[/tt]
The color codes are as follows:

Red: Physical Device Controls, Format Effectors
Brown: Physical Device Controls, Other
Green: Logical Communications Controls
Cyan: Physical Communications Controls
Blue: Information Separators
Magenta: Controls for Code Extensions

If you really want to display control characters on the screen, though, you may have to resort to direct video memory alteration. The following [tt]SUB[/tt] automates this process:
[tt]
SUB placeChar(row%, column%, asciiValue%, attributes%)
IF (row% < 1) OR (row% > 60) THEN ERROR 5
IF (column% < 1) OR (column% > 80) THEN ERROR 5
DEF SEG = &HB800 ' Use &HB000 for old monochrome displays in case &HB800 does not work
linearOffset% = 2 * (row% * 80 + column% - 81)
POKE linearOffset%, asciiValue%
POKE linearOffset% + 1, attributes%
END SUB
[/tt]
You may also wish to use the following sub to create the [tt]attributes%[/tt] value automatically:
[tt]
FUNCTION makeAttributes%(foreColor%, backColor%, blinking%)
attributes% = (foreColor% AND 15) OR (16 * (backColor% AND 7))
IF blinking% THEN attributes% = attributes% OR 128
makeAttributes% = attributes%
END FUNCTION
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top