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 >
Text File  |  1987-04-22  |  7KB  |  143 lines

  1.                                   ASCII
  2.                                   *****
  3.  
  4.                             BY BRIAN CROSSLAND
  5.                             ******************
  6.  
  7. Hello..first a small introduction, you may have read my letter to STOSSER 
  8. in issue 7.  Part of the letter was a  small  gripe  about the lack of REM
  9. statements in some of the giveaways.  After sending off  the letter I 
  10. decided to take a small routine and sort out what  was  happening to see 
  11. just how much work is involved.   The routine used ASCII codes to control 
  12. the appearance of the scroller.
  13.  
  14. The experience made me realise how unrealistic it was of me to expect the 
  15. people at STOSSER to do this for every listing, quite simply, i found that 
  16. it takes far too long.  However it gave me an idea for an article that I 
  17. could contribute to the diskzine.
  18.  
  19. This article is all about ASCII.
  20.  
  21. In order to process characters that do not have a numeric value in the 
  22. computer, e.g. a,b,c,?,!,+, a code has been devised that assigns a unique 
  23. bit combination to each character.  Characters are held in the computer's  
  24. memory as bit mapped images, each image being made up of a number of dots.
  25. The code identifies which image is to be presented to the screen.
  26.  
  27. This is the ASCII code.  ASCII stands for the American Standard Code for 
  28. Information Exchange and was developed by the American National Standards
  29. Institute in 1963.
  30.  
  31. The ASCII system assigns a code number to :
  32.  
  33. Each character in the alphabet.
  34. Each numeral.
  35. Punctuation marks and arithmetic symbols.
  36. A set of commands.
  37.  
  38. ASCII uses numbers to represent characters, and it is these numbers that 
  39. are stored in the computers memory, and also what are used when comparing 
  40. strings.  The ASCII code ranges from 0 to 127. The codes 0 through 31 are
  41. the control characters which are used by programs to send special commands 
  42. such as underlined text, cursor control etc.The numerals 0 to 9 have ASCII  
  43. codes 48 to 57, the capital letters A to Z have ASCII codes 65 to 90, and 
  44. the small letters have codes 97 to 122. The remaining places are filled 
  45. with various symbols and punctuation marks.  Any given lowercase letter 
  46. has a value that is greater by 32 than its corresponding uppercase letter.
  47.  
  48. When a sort is performed on strings, they are sorted into ASCII order 
  49. rather than alphabetically, so that capital Z's will be placed before 
  50. small a's.
  51.  
  52. The ASCII code is an seven bit binary code.  Using seven bits gives the 
  53. range of 0 to 127 ( 000 0000 to  111 1111 ).  For convenience of operation 
  54. ASCII characters  are  usually represented with eight bits which makes an  
  55. ASCII  character  one byte wide.  Most systems do not make  use  of  the  
  56. eighth bit under  normal operating modes.  This bit, the most  significant 
  57. bit, (The one at the left hand end) is always set to zero.  The eighth bit 
  58. may  be used for parity checking which is a simple method of checking  the 
  59. integrity of received data.
  60.  
  61. Although only codes 0  to  127  are  defined many programmes and printers 
  62. use codes 128 to  255  for  special purposes such as graphics output. The 
  63. portion between 127 and 255 is known as the extended ASCII set. Because it 
  64. makes use of the most significant bit the extended set cannot be used at 
  65. the same time as using it for parity checking.
  66.  
  67. If you load the accessory  "ASCII.ACB" into STOS you will see a display of 
  68. the STOS ASCII table.  In STOS the ASCII characters from 192 to 255 are 
  69. the graphics used to produce the borders of windows.
  70.  
  71. The use of the ASCII code allows text produced by one application or 
  72. machine to be read by another, such as an ST to a Macintosh.  It enables 
  73. programmes such as STOS to be written in a word processor and imported 
  74. into STOS as an .ASC file.
  75.  
  76. Although it may not immediately seem so, the codes are highly orderly, if 
  77. one looks at the code in its seven bit binary form.  The numerals 0 to 9 
  78. start at position 48, 011 000 in binary, to 57, 011 1001. If the top three  
  79. bits  are  ignored  then the binary pattern corresponds with the decimal 
  80. integer represented.  Similarly the upper and lower cases of the alphabet 
  81. start with 'A' and 'a' coded as one.  'A' being 65 or 100 0001 and 'a' 
  82. being 97 or 110 0001.
  83.  
  84. As mentioned previously the Control Codes cause things to happen such as 
  85. carriage return or linefeed on a printer and are not characters printed to 
  86. the screen .
  87.  
  88. If you have a printer manual you should find a list of the ASCII codes and 
  89. how the control codes are interpreted by the printer. The normal emulation 
  90. modes for printers are Epson and IBM.  Examination of the extended ASCII 
  91. set , i.e. numbers 128 to 255 shows italics on the standard Epson 
  92. character set  but graphic symbols on the IBM.
  93.  
  94.      In the STOS manual you can find the following Control Codes :
  95.  
  96.      chr$(3)..............    Cursor Left
  97.      chr$(9)..............    Cursor Right
  98.      chr$(10).............    Cursor Down
  99.      chr$(11).............    Cursor Up
  100.  
  101. Here are some more, as far as I am aware they are not given in the manual.
  102.  
  103.      chr$(4)..............    Scroll Up
  104.      chr$(5)..............    Scroll Down
  105.      chr$(12).............    CLS ( Clear Screen )
  106.      chrs(20).............    Cursor Off
  107.      chr$(21).............    Inverse On
  108.      chr$(22).............    Shade on
  109.      chr$(30).............    Cursor Home
  110.      chr$(31).............    Underline On
  111.  
  112. The last six are courtesy of the late STOS magazine by Dion Guy.
  113.  
  114. The main commands used in conjunction with the ASCII code are CHR$ and 
  115. ASC.
  116.  
  117. CHR$ is the command that is used to convert an ASCII code number to its 
  118. text equivalent,unless that is, the ASCII number refers to a control code.
  119. Hence : Print chr$(65) results in capital 'A' being placed on screen.
  120. However if you were to enter print chr$(31) the only response would be 
  121.  
  122. OK.
  123.  
  124. Chrs$(31) is one of the  control  codes  given above and does not print to 
  125. screen but its effect is  seen, the OK and subsequent text is underlined.
  126.  
  127. If you wish to see what the ASCII code of a particular character is then 
  128. the command ASC is used.  Hence print ASC("A") gives the result 65.  If 
  129. print ASC("Able" ) is  entered  then  the  result is again 65, this is 
  130. because ASC(A$) returns the  ASCII code of the FIRST character of the 
  131. string in A$.
  132.  
  133. The following small programme prints the ASCII numbers of your name.
  134.  
  135.      10   input " Type in your name : "; NAM$
  136.      15   print
  137.      20   for I = 1 to len(NAM$)
  138.      30   C$=MID$(NAM$,I,1)
  139.      40   Print C$;"   is   ASCII code number  ";asc(C$)
  140.      50   next I
  141.  
  142.                                                 Cheers...........
  143.