home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TCE Demo 2
/
TCE_DEMO_CD2.iso
/
demo_cd_.2
/
mags
/
stosser
/
stoser09.arj
/
stoser09.msa
/
ISSUE_9
/
31.PNE
< prev
next >
Wrap
Text File
|
1987-04-22
|
7KB
|
143 lines
ASCII
*****
BY BRIAN CROSSLAND
******************
Hello..first a small introduction, you may have read my letter to STOSSER
in issue 7. Part of the letter was a small gripe about the lack of REM
statements in some of the giveaways. After sending off the letter I
decided to take a small routine and sort out what was happening to see
just how much work is involved. The routine used ASCII codes to control
the appearance of the scroller.
The experience made me realise how unrealistic it was of me to expect the
people at STOSSER to do this for every listing, quite simply, i found that
it takes far too long. However it gave me an idea for an article that I
could contribute to the diskzine.
This article is all about ASCII.
In order to process characters that do not have a numeric value in the
computer, e.g. a,b,c,?,!,+, a code has been devised that assigns a unique
bit combination to each character. Characters are held in the computer's
memory as bit mapped images, each image being made up of a number of dots.
The code identifies which image is to be presented to the screen.
This is the ASCII code. ASCII stands for the American Standard Code for
Information Exchange and was developed by the American National Standards
Institute in 1963.
The ASCII system assigns a code number to :
Each character in the alphabet.
Each numeral.
Punctuation marks and arithmetic symbols.
A set of commands.
ASCII uses numbers to represent characters, and it is these numbers that
are stored in the computers memory, and also what are used when comparing
strings. The ASCII code ranges from 0 to 127. The codes 0 through 31 are
the control characters which are used by programs to send special commands
such as underlined text, cursor control etc.The numerals 0 to 9 have ASCII
codes 48 to 57, the capital letters A to Z have ASCII codes 65 to 90, and
the small letters have codes 97 to 122. The remaining places are filled
with various symbols and punctuation marks. Any given lowercase letter
has a value that is greater by 32 than its corresponding uppercase letter.
When a sort is performed on strings, they are sorted into ASCII order
rather than alphabetically, so that capital Z's will be placed before
small a's.
The ASCII code is an seven bit binary code. Using seven bits gives the
range of 0 to 127 ( 000 0000 to 111 1111 ). For convenience of operation
ASCII characters are usually represented with eight bits which makes an
ASCII character one byte wide. Most systems do not make use of the
eighth bit under normal operating modes. This bit, the most significant
bit, (The one at the left hand end) is always set to zero. The eighth bit
may be used for parity checking which is a simple method of checking the
integrity of received data.
Although only codes 0 to 127 are defined many programmes and printers
use codes 128 to 255 for special purposes such as graphics output. The
portion between 127 and 255 is known as the extended ASCII set. Because it
makes use of the most significant bit the extended set cannot be used at
the same time as using it for parity checking.
If you load the accessory "ASCII.ACB" into STOS you will see a display of
the STOS ASCII table. In STOS the ASCII characters from 192 to 255 are
the graphics used to produce the borders of windows.
The use of the ASCII code allows text produced by one application or
machine to be read by another, such as an ST to a Macintosh. It enables
programmes such as STOS to be written in a word processor and imported
into STOS as an .ASC file.
Although it may not immediately seem so, the codes are highly orderly, if
one looks at the code in its seven bit binary form. The numerals 0 to 9
start at position 48, 011 000 in binary, to 57, 011 1001. If the top three
bits are ignored then the binary pattern corresponds with the decimal
integer represented. Similarly the upper and lower cases of the alphabet
start with 'A' and 'a' coded as one. 'A' being 65 or 100 0001 and 'a'
being 97 or 110 0001.
As mentioned previously the Control Codes cause things to happen such as
carriage return or linefeed on a printer and are not characters printed to
the screen .
If you have a printer manual you should find a list of the ASCII codes and
how the control codes are interpreted by the printer. The normal emulation
modes for printers are Epson and IBM. Examination of the extended ASCII
set , i.e. numbers 128 to 255 shows italics on the standard Epson
character set but graphic symbols on the IBM.
In the STOS manual you can find the following Control Codes :
chr$(3).............. Cursor Left
chr$(9).............. Cursor Right
chr$(10)............. Cursor Down
chr$(11)............. Cursor Up
Here are some more, as far as I am aware they are not given in the manual.
chr$(4).............. Scroll Up
chr$(5).............. Scroll Down
chr$(12)............. CLS ( Clear Screen )
chrs(20)............. Cursor Off
chr$(21)............. Inverse On
chr$(22)............. Shade on
chr$(30)............. Cursor Home
chr$(31)............. Underline On
The last six are courtesy of the late STOS magazine by Dion Guy.
The main commands used in conjunction with the ASCII code are CHR$ and
ASC.
CHR$ is the command that is used to convert an ASCII code number to its
text equivalent,unless that is, the ASCII number refers to a control code.
Hence : Print chr$(65) results in capital 'A' being placed on screen.
However if you were to enter print chr$(31) the only response would be
OK.
Chrs$(31) is one of the control codes given above and does not print to
screen but its effect is seen, the OK and subsequent text is underlined.
If you wish to see what the ASCII code of a particular character is then
the command ASC is used. Hence print ASC("A") gives the result 65. If
print ASC("Able" ) is entered then the result is again 65, this is
because ASC(A$) returns the ASCII code of the FIRST character of the
string in A$.
The following small programme prints the ASCII numbers of your name.
10 input " Type in your name : "; NAM$
15 print
20 for I = 1 to len(NAM$)
30 C$=MID$(NAM$,I,1)
40 Print C$;" is ASCII code number ";asc(C$)
50 next I
Cheers...........