78N94^110n126~ 47/63?79O95_111o127"> 78N94^110n126~ 47/63?79O95_111o127">
Download presentation
Presentation is loading. Please wait.
Published byRafe Nash Modified over 9 years ago
1
Manipulating Characters In today’s lesson we will look at: how text is stored inside the computer how we can use BASIC functions to manipulate and encipher text
2
All types of data are stored inside the computer as numbers: –for images, the number represents the colour of each pixel –for sound, the number represents how loud the sound is for each fraction of a second –for text, a numerical code is stored that represents each character The most common method for coding text on a PC is called ASCII – the American Standard Code for Information Interchange How Is Text Stored?
3
ASCII Codes ASCIISymbolASCIISymbolASCIISymbolASCIISymbolASCIISymbolASCIISymbol 32(space)48064@80P96`112p 33!49165A81Q97a113q 34"50266B82R98b114r 35#51367C83S99c115s 36$52468D84T100d116t 37%53569E85U101e117u 38&54670F86V102f118v 39'55771G87W103g119w 40(56872H88X104h120x 41)57973I89Y105i121y 42*58:74J90Z106j122z 43+59;75K91[107k123{ 44,60<76L92\108l124| 45-61=77M93]109m125} 46.62>78N94^110n126~ 47/63?79O95_111o127
4
The ASC() function takes a character and returns the corresponding ASCII code. For example: PRINT ASC(“A”) PRINT ASC(LEFT$(“Hello”, 1)) The output of these two lines of code is 65 and 72 respectively. The ASC Function
5
The CHR$() function takes an ASCII code and returns the corresponding character. For example: PRINT CHR$(65) PRINT CHR$(ASC(“a”)-32) The output of these two lines of code is A in both cases. The CHR$ Function
6
e.g. How would you capitalise a name? input "What is your name? "; n$ if asc(left$(n$,1))>96 then n$ = chr$(asc(left$(n$,1))-32) + right$(n$, len(n$)-1) print "Did you mean "; n$; "?" else print "Hello "; n$; ", nice to meet you!" end if Combining the Techniques
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.