Appendix A: ASCII Codes

Appendix A: ASCII Codes

Appendix A: ASCII Codes Hex Character Hex Character Hex Character Hex Character code code code code 0 NUL 20 (space) 40 @ 60 1 SOH 21 ! 41 A 61 a 2 STX 22 II 42 B 62 b 3 ETX 23 # 43 c 63 c 4 EOT 24 $ 44 D 64 d 5 ENQ 25 % 45 E 65 e 6 ACK 26 & 46 F 66 f 7 BEL 27 47 G 67 g 8 BS 28 ( 48 H 68 h 9 HT 29 ) 49 I 69 A LF 2A * 4A J 6A j B VT 2B + 4B K 6B k c FF 2C 4C L 6C I D CR 2D 4D M 6D m E so 2E 4E N 6E n F SI 2F I 4F 0 6F 0 10 DLE 30 0 50 p 70 p 11 DCl 31 1 51 Q 71 q 12 DC2 32 2 52 R 72 r 13 DC3 33 3 53 s 73 s 14 DC4 34 4 54 T 74 t 15 NAK 35 5 55 u 75 u 16 SYN 36 6 56 v 76 v 17 ETB 37 7 57 w 77 w 18 CAN 38 8 58 X 78 X 19 EM 39 9 59 y 79 y lA SUB 3A 5A z 7A z lB ESC 3B 5B [ 7B { lC FS 3C < 5C \ 7C I lD GS 3D = 5D ] 7D } lE RS 3E > 5E t 7E lF us 3F ? 5F 7F (delete) 357 358 Introduction to Computing The characters in the first column are control characters; they may be produced from the keyboard by depressing the crRL key and the corresponding key from the third column simultaneously. For example, ASCII code &lB can be produced by the combination crRL-[. Several control characters can be produced by special keys, as follows: BS backspace HT tab LF linefeed CR return ESC escape DCl to DC4 are device control codes; DCl and DC3 are frequently used to control scrolling of the screen. crRL-G (bell) sounds an audible tone. CfRL-L (form feed) is used to start a new page on a printing device. The other control codes are mainly used in connection with data transmission. Appendix B: Other BASICS The version of BASIC used in this book is BBC BASIC. Initially introduced on the Acorn BBC computer in 1981, it has become the standard BASIC, available not only on Acorn computers, but indeed on all computers intended for the educational user. However, for the benefit of readers who prefer to use RM BASIC (the version supplied with the RM range of computers) or BBC BASIC V (installed in the Acorn Archimedes), this appendix highlights some of the important diffe­ rences. RM BASIC RM BASIC includes a number of improved program structures, as well as one or two important notational differences from BBC BASIC. Assignment symbol The preferred assignment symbol is : = but = is also accepted. Loops The repetitive constructs are FOR/NEXT and REPEAT/UNTIL as in BBC BASIC. Branches The alternative construct IF ... THEN ... ELSE (on a single line) is available as in BBC BASIC. Subprograms The major differences between RM BASIC and BBC BASIC are in the definition and use of subprograms. In RM BASIC any legitimate identifier may be used to name a subprogram-it does not have to begin with FN or PROC. Procedures A procedure definition begins with the reserved word PROCEDURE, and the parameters are not enclosed in brackets. In addition, it is possible to call 359 360 Introduction to Computing parameters by reference, and arrays may be passed as parameters. By way of example, here is how the output_bill procedure (section 3.4) would be coded in RM BASIC. 500 510 PROCEDURE Output_bill name$, address$, teLno$, rentaLcharge, calLcharge 520 530 vat : = 0.15 : REM constant value 540 PRINT name$ ! address$ ! teLno$ 550 REM ***output charges*** 560 PRINT "apparatus:'', rentaLcharge 570 PRINT "calls:", calLcharge 580 vat_charge := vat*(rentaLcharge + calLcharge) 590 PRINT "vat:", vat_charge 600 PRINT "total:", rentaLcharge + calLcharge + vat_charge 610 ENDPROC There is no LOCAL declaration in line 520 as all identifiers are automa­ tically local in RM BASIC unless specified to be global. On those occasions where a global variable is required, this is achieved by a GLOBAL declaration which must appear as the first line in the main program (or the subprogram which calls the procedure) and as the first line in the body of the procedure definition. The main program of the Telecom billing system which calls this procedure looks like this in RM BASIC: REM** *Telecom billing*** INPUT telephone_no$, name$, address$ INPUT number_oLtelephones, initial, final used : = final - initial Compute_charges number_oLtelephones, used RECEIVE rentaLcharge, calLcharge Output_bill name$, address$, telephone_no$, rentaLcharge, calLcharge END This program illustrates the use of output parameters, which must follow all the input parameters and be prefixed by the reserved word RECEIVE. A procedure definition with formal output parameters is coded as follows: PROCEDURE Compute_charges no_oLtelephones, used RETURN rentaLcharge, calLcharge REM CONSTANTS line_charge := 13.60 receiver_rental : = 2.45 unit:= 4.4: REM pence REM BEGIN Appendix B: Other BASICS 361 rentaLcharge := line_charge + (no_oLtelephonesHeceiver_rental) calLcharge : = used*unit/100 ENDPROC Note how the reserved word RETURN takes the place of var in Pascal. However, in RM BASIC, if a variable is used as both an input and output parameter, it must appear in both lists-before and after RETURN. RM BASIC makes some provision for exception handling within procedures (section 4.3). The LEAVE command may be used to cause a premature exit from a procedure to the calling statement. Functions Function definitions begin with the reserved word FUNCTION and finish with ENDFUN. A value is returned to the calling statement using the reserved word RESULT. Here is the wage function (section 3.4). 1200 1210 FUNCTION Wage(rate, hours) 1220 1230 IF hours < = 38 THEN wageO : = hoursHate ELSE wageO := (38 + (hours- 38)*1.5)Hate 1240 RESULT wageO 1250 ENDFUN 1300 1310 FUNCTION Tax(gross) 1320 RESULT 0.25*gross 1330 ENDFUN An array parameter is passed by reference, just like a var parameter in Pascal. No specification is required. The following is the RM BASIC version of the linear search function in exercise 11 of chapter 3. FUNCTION Searchl(data$(), size, item$) index : = size + 1 REPEAT index : = index - 1 UNTIL data$(index) =item$ OR index= 0 RESULT index END FUN Since data$() is passed as a parameter rather than a global variable, the actual array could be called something else other than data$. In fact, in RM BASIC it is not even necessary to pass size as a parameter, because there is a built-in function BOUNDS which can determine the size of an array. This covers very briefly the major structural differences between BBC BASIC and RM BASIC. 362 Introduction to Computing BBC BASIC V The extended version of BBC BASIC supplied with the Acorn Archimedes range of microcomputers is also available on some other computers. The following significant extensions implement some of the structures discussed in this book. Loops In addition to fixed loops and until loops, BBC BASIC V implements while loops. The syntax is WHILE <condition> DO <statements> ENDWHILE Branches Most versions of BASIC to data have provided the single-line IF ... THEN ... ELSE as the only alternative construct. As a result the only practical way of implementing a branch is often by the introduction of procedures for the conse­ quent statements. In BASIC V, there is a proper IF statement which can be used to code a two-way branch: IF <condition> THEN <statements> ELSE <other statements> END IF There is also a CASE statement to code a multi-way branch. Array operations A useful feature in BASIC V is that the array is a fully supported data structure, with operations on whole arrays. Thus a single statement can be used for an operation on a whole array. The following illustrates the use of array operations on compatible arrays. DIM a(200), b(200), m(lOO, 200) a()= 6•b{) b() =a()+ b{) a()= m{)•b{) Appendix C: Coursework and Projects The Common Core in Computing at Advanced Level, as published by the GCE Examining Boards [Common Cores at Advanced Level-First Supplement (GCE Boards of England, Wales and Northern Ireland, 1987)], contains the following statement: Project work should (a) encourage the sensible use of computers to solve problems which are within the experience or understanding of the candidate; (b) emphasise the analysis and design skills involved in problem solving using the computer and so involve the development of a piece of work over an extended period of time; (c) involve the development, documenting, implementing and testing of a software based package which might or might not include the use of pre-written software; (d) involve the organisation and presentation of a report on the work that has been carried out, including an evaluation of this work. Typically the project will count for about 25 per cent of the marks, and so will need to be a substantial piece of work. Candidates following the usual two-year course should select a project topic at ~he end of the first term. This will leave a clear period of fourteen months over which to develop the project in time for completion during the fifth term. Any application area is acceptable, but in practice a candidate must choose an application which is not too difficult to analyse and also not too time-consuming to be completed in good time. Stock control, a spelling checker, crossword-solving aid and invoicing are just a few areas which could form the basis for a suitable problem. Other project ideas may be found in the contexts of the following exercises set in this book: exercise 2.3 (bank transactions), further exercise 2.3 (timetable), further exercise 7.1 (payroll).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    34 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us