Calculators

Reference / Paper · 1986

Using and Programming the Psion Organiser II

Read the PDF ↗

A book on using and programming the Psion Organiser II in OPL.

Author
Shaw
Year
1986
Type
Reference / Paper
Credit
Scan via the Internet Archive.

← Back to the Reference Library

Using and Programming the Psion Organiser II

Using and Programming the A complete guide by f= Mike Shaw GS Using and Programming Psion Organiser II A complete guide USING AND PROGRAMMING PSION ORGANISER II A complete guide Mike Shaw To my lovely Annie, who made it all worthwhile. Published by KUMA COMPUTERS LTD. First Published 1986 2nd Revision August 1987 Kuma Computers Ltd. Unit 12, Horseshoe Park Horseshoe Road, Pangbourne, Berkshire RG8 7JW Telex 846741 KUMAG Tel 07357 4335 Copyright © 1986 Mike Shaw Printed in Great Britain ISBN 07457-0134-5 This book and the programs within are supplied in the belief that its contents are correct and they operate as specified, but Kuma Computers Ltd. (the Company) shall not be liable in any circumstances whatsoever for any direct or indirect loss or damage to property incurred or suffered by the customer or any other person as a result of any fault or defect in goods or services supplied by the company and in no circumstances shall the company be liable for consequential damage or loss of profits (whether or not the possibilty thereof was seperately advised to it or reasonably foreseeable) arising from the use or performance of such goods or services. ALL RIGHTS RESERVED No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without prior written permission of the author and publisher. The only exception is the entry of programs contained herein onto a Psion Organiser II for the sole use of the owner of this book. Acknowledgements No detailed book about a new product could ever be written without the support of the manufacturer. This book is no exception: I am deeply indebted to all at Psion for the considerable enthusiasm they showed for the project, and for the encouragement, guidance, advice and help they provided during its preparation. I would like to thank especially Martin Stamp for painstakingly reading the manuscript and making invaluable suggestions (and corrections): in so doing, I would not wish to detract from the generous assist- ance provided by the entire team, without which this book would never have seen the light of day. CONTENTS PART 1. HOW ORGANISER WORKS 11 1.2 1.3 1.4 The Warehouse Concept, 2 Putting you in the picture; Little boxes; The busy ‘Office’; The power to work; Keeping in touch; Special duty departments; Summary. The Memory Boxes, 7 More than one type; Look-in only boxes; Put-in look-in and change boxes; Put-in, look-in, lock-up boxes; What goes into the boxes; Computers count differently; Storing ‘characters’; Storing instructions; Storing values; Instruction, character or value?; Summary. Following Instructions, 18 The Jolly Instruction Man; The Translation Service; Where is the next instruction?; Excuse the interruption; What would you like to do?; Saving and Finding; Using the Calculator; Using the other options; Summary. Obeying Program Instructions, 30 Programs and Procedures; Three ways to run a program; Running a program; Summary. PART 2. USING THE BUILT-IN APPLICATIONS 2.1 2.2 Getting to grips with the keyboard, 36 Not like a calculator; Selecting CAPS, lower case or NUMbers; The cursor keys; The CLEAR/ON key; The MODE key; The DELete key; The EXEcute key; Special keys. The main Menu, 41 Switching on; Selecting an option; Customizing the main Menu; The INFO option; The RESET option; Switching off. 2.3 2.4 2.5 2.6 Time and Alarms, 46 Keeping TIME; Using the ALARMS. Keeping Records, 49 The built-in filing system; Storing your information; Locating information; Changing record information; Removing records from a file; Copying a complete file; Copying one MAIN file record. Keeping a Diary, 58 The DIARY Menu; The PAGE option; The LIST option; The FIND option; The GOTO option; The TIDY option; Using the DIARY; Keeping more than one DIARY. Using the Calculator, 68 ; Before you start; Fixing the decimal point; Entering a calculation; Very large numbers; The order in which calculations are made; Using the Calculator memories; The built-in functions; Using your own functions; When things go wrong. PART 3. PROGRAMMING ORGANISER II 3.1 3.2 3.3 3.4 The principles of programming, 81 __ What is programming?; Defining the requirement; Plan the program flow; Summary. Using the program Menu, 91 : The PROGramming options; The NEW option; The EDIT option; The RUN option; The ERASE option; The DIR option; The LIST option. . Introducing the programming language, 101 The types of instruction; Separating instructions; The unknown quantities - variables; Array variables; Choosing variable names; LOCALS, GLOBALs and parameters; Non-declared variables; When things go wrong. From Keyboard to Screen, 113 Creating a Procedure; Naming the procedure; Declaring numeric variables; Assigning values to variables; Calling one procedure from another. 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 Handling Characters and Strings, 127 Declaring string variables; Joining strings together; Non-keyboard characters; Cutting the strings; How long is a string?; Where's that string?. Decision making, 140 Putting things to the test; The Test operators; IF a comparison is true; IF-IF-IF instructions; Using AND and OR to link comparisons; A ‘Password’ procedure. Creating options and jumping around, 152 Offering a Menu; Jumping away; The Decorating Materials program. More Keyboard and Screen handling, 163 Has a key been pressed?; Hang on a moment; Setting up the keyboard; Where’s the cursor?; Viewing a string. Looping round until the job is done, 172 Keep going until-; WHILE a condition is true; DO until a condition is true; Nesting loops; Breaking out of a loop; Making a REMark; Target game program. Converting variables, 183 A change is needed; Converting a string to a number; Converting numbers to strings; Converting one numeric type to another. Built-in data available on demand, 190 Time-related information; How much memory is left?; Mathematical values. The sound of music, 194 Organiser’s beep show; Keyboard music-maker; Sound effects. Files - Creating and Opening, 200 Introduction to files; What goes into a file; The file handling process; Creating a file; Opening a file. Files — writing and changing records, 207 Putting information on record; Adding a new record; Changing a complete record; See what you are changing; Maximum record size; Selecting which file to use. 3.15 Files— handling records, 214 What record do you want?; Step by step; Searching for specific information; Going straight to a record number; How many records are there?; Viewing your records; Erasing an unwanted record; Closing a file. 3.16 File Management, 224 , Looking after your files; Examine file names; Datapak free space; Deleting a file; Copying files; The main File Management procedure. 3.17 Errors and bugs, 232 When your slip shows; The error messages; Trapping any error; Trapping specific instruction errors; When Organiser goes into a never-ending loop; Finding bugs. 3.18 Machine level instructions, 244 A word of caution; Locating variables in memory; Examining the contents of memory; Changing memory contents; Defining your own characters; Machine language programs. APPENDIX 253 ASCII - Character patterns Illustrations 3.1.1 Flowcharts to calculate percentage a smaller number is of a larger number. 3.1.2 Typical Arcade game flowchart. 3.1.3 ‘Update the Score’ flowchart. 3.1.4 Calculation of Decorating Materials flowchart. 3.3.1 The use of GLOBAL variables 3.9.1 Flowchart for ‘Target’ game. 3.18.1 Character definition grid. Programs Note that only complete procedures and programs are listed here: for illustrative program sections, see the relevant Chapters. 3.4.1 3.4.2 3.4.3 3.4.4 3.5.1 3.5.2 PF - percentage function, PF — percentage function, shortened version. PC - percentage program. OPF - original] price function. GO — to switch off and ‘welcome back’. MONTH - Month name from its number. CNTR - Function to centralise a display. TEST1 - to test CNTR procedure. MONTHNOY - find month number from its name. TEST2 - to test MONTHNOY procedure COW% — Ceiling or walls? (Decorating program) CALEM% - Calculation of Emulsion, long version. (Decorating program) CALEM% - Calculation of Emulsion, short version. (Decorating program) CALPAP% — Calculation of paper. (Decorating program) DECOR - Decorating materials program program. WAIT - Demonstration of ‘PAUSE’ (1). WAIT - Demonstration of ‘PAUSE’ (2). KTEST — Keyboard input tester. MTABLE - Multiplication Table (WHILE/ENDWH). MTABLE2 ~ Multiplication Table (DO/UNTIL). CHARDIS - Display of character patterns. RND% - Random numbers for Target game. DELAY - Delays for Target game. TARGET - Main game procedure. HEX - Converting decimal to hexadecimal. TIMER - A simple timing procedure. BP -— BEEP function for frequency inputs. PLAY ~— Making Organiser a keyboard instrument. PHONE -— Telephone sound effect. ALM - Alarm type signal. SFX - Sound effects sampler. FDIR — File name Directory. FSPACE — Memory left on a Datapak. FDEL - Delete a file. FREN - Rename a file. FMAN - File management main procedure. LOG - Demonstration of ONERR. TRAPPER - Demonstration of TRAP instruction. CHRPAT - Character definition control program. CHRDEF ~ Defining a character. CHRSAV - Saving defined character to a file. CHRLD - Load a pre-saved character pattern. PREFACE Mike Shaw's skills include the rare combination of the professional copywriter and the computer buff. He has a remarkable gift for capturing complex or wide concepts and communicating and explaining them with simplicity. As a result, this book can be read with benefit by the expert and uninitiated alike: for the uninitiated, it provides probably the best explanation I have read of how a computer works. The technology behind Organiser II is a classic example of the application of state-of-the-art microelectronics, resulting in a compact machine that is ‘high-powered’ yet low on power con- sumption. I believe that ‘hand computers’ will become as common- place as telephones or calculators within a few years. Organiser II is possibly the first of such machines to provide real utility, versatility and breadth, the first practical computer to fit the pocket ~ metaphorically as well as physically, This book provides an excellent description of that utility and versatility, and illuminates the opportunities made available by Organiser II. It opens the mind wide to the application and potential of the product, while giving an imaginative description of how a computer works and how, in real time, Organiser II performs a multiplicity of different tasks. The author's allegorical figure, JIM, portrays beautifully the huge detail and mechanics of the tasks that the machine must continually perform. One is left with a clear understanding — as well as exhaustion at JIM’s immense ‘busy-ness’. The book also takes the reader steadily through the concepts of programming, explaining how to customize Organiser IT. This is complemented by many fascinating and varied examples of applic- ations — from the calculation of decorating materials to playing music, from file-handling to a simple game ~ examples which illustrate the possibilities and enhance the understanding of its potential. Mike Shaw has been involved in the project as a professional communicator from the development phases. His excitement and enthusiasm has led to the creation of this book, which will be an invaluable guide to the many thousands of people who own an Organiser II. David E. Potter MA (Cantab.) PhD (Lond.) Chairman, Psion Ltd. October 1986 PART 1 How Organiser II works In learning how to use any piece of equipment to its best advantage, it often helps to under- stand first a little about how it operates. The aim of this part of the book is to give you an idea of the way Organiser II works - not in great technical detail, but in general terms, by the use of an analogy. How Organiser works 11 THE WAREHOUSE CONCEPT Putting you in the picture Before discussing how Organiser II tackles all the different functions it provides, let us first create a mental picture of its construction. You may well have heard some of the language that is associated with computers ... words such as integrated circuits, bytes, pro- cessors, RAM and so on. For the time being, forget them all. Instead, consider the Organ- iser IT not as a computer, but as a large, very busy warehouse that undertakes work on our behalf. We are going to use this concept to describe its construction and how it works. The description given will, of course, be analogous to the actual way Organiser operates. Nevertheless, the picture created will be sufficiently accurate in principle to enable the more important parts of its inner workings to be appreciated. You may now be asking why you need to understand a little about how Organiser II works before you learn to program it. After all, one can learn to drive a car without knowing how the engine works. The answer is simple. You are not going to learn how to just drive the Organiser — you drive it when you use the built-in functions such as the Diary or Alarms. You are going to learn how to build in extra functions to suit your own needs ... you are going to customize the engine to do what you want. And to do that it helps to know, even roughly, how it works, Little boxes So. Organiser II can be considered as a large warehouse. If you look inside, one of the first things you'll notice is that there are thousands upon thousands of small boxes, neatly laid out in an orderly fashion. Each box is individually numbered — rather like the houses in a street. And as with houses in a street, this number is called its ‘address’. It enables the box to be located very quickly when the need arises. The boxes are used to store information for the running of the warehouse, and for handling any work that the warehouse may be asked to do on our behalf. Because they store information, collect- ively they are called the memory. The size of the memory is simply the number of boxes available to carry information. Along the side of the warehouse there are two ‘doors’, to which can be driven’ pantechnicons’ containing even more boxes. These 2 1.1 The Warehouse Concept ‘doors’ are the slots in the side of your Organiser II, and the ‘pantechnicons’ are Datapaks or Program Packs. There is no limit to the number of Datapaks or Program Packs that can be used with Organiser II, although of course only two can be connected at a time. In Chapter 1.2, we’ll take a closer look at the boxes, to examine the different types used and to see exactly what goes into them. But for the time being, let us continue with our general exploration ... The busy ‘Office’ Tucked away in the heart of the Organiser warehouse there is a small Office, the nerve centre of the entire operation. Very little happens in the warehouse this Office doesn’t know about. It controls. It organises (yes, even the Organiser II needs an organ- iser!), And it handles simple mathematical tasks such as adding or subtracting. This Office, as you will appreciate, is kept very busy indeed. But in spite of that, it works extremely fast. So fast, it can handle thousands upon thousands of instructions before you could bat an eyelid. Which by any standards, is pretty fast. The technical name for this Office is Central Processor Unit, or CPU for short. For the time being at least, we shall continue to refer to it as the Office. It sounds less daunting. Unlike its counterpart in most other computer ‘warehouses’, this Office never closes: as long as it has the power, ‘someone’ is always on duty. The power to work Which brings us to another element in our warehouse: the power supply. Down in the ‘basement’ there is a battery which provides all the power that’s needed. There is also provision, behind a sliding hatch at the top, for connecting Organiser II to a mains supply, using the correct lead. Even when to all intents and purposes the warehouse is ‘off duty’ (that is to say, when the Organiser II is switched off), a ‘manager’ remains on duty. He sees to it that the Clock and Calendar functions, for example, are kept working, so you always have the correct time and date available when you switch on. Also, if you have set Organiser II to give you an Alarm call, he will know about it and act accordingly when the time comes. The power consumed during these off-duty periods is fairly small. When ‘on duty’, the activity is greater of course, and the power consumption is higher. If at any time there isn’t enough power in the battery to perform ‘on duty’ work then, via the Office, you will be given the message LOW BATTERY. (When you see that message, switch off immediately). Fortunately, Organiser II has a small back-up reservoir of power. 3 How Organiser works In the event of the power supply being missing altogether (i.e., if the battery is removed), this reservoir will keep the time and date ticking over for about 30 seconds. This gives you ample time to change the battery without having to reset the time and date again afterwards. As we shall see, some of the memory boxes inside the Organiser also need a power supply to keep them operational. The back-up reservoir of power will keep these going for about 90 seconds after the battery has been removed. So the chances of losing any of the information contained in these boxes — your valuable information — is made less likely. However, it is important that notice is taken of the LOW BATTERY message: if you don’t switch off immediately, there may be insufficient power left in the reservoir to give you time to change the battery. Always switch off before changing the battery. Keeping in touch Back to the warehouse concept. All of the memory boxes and the busy Office would be absolutely useless if we were unable to communicate with them. We, after all, are the ‘customers’ who decide what we want the warehouse to do for us. So we need a way to ‘talk’ to the Office. This is achieved through the keyboard, used to tap out our instructions. Similarly, the Office needs to communicate with us — to help us choose what we want to do, to show us what we are doing at the keyboard, and to provide the answers to our requests. The Office’s communications appear on the screen above the keyboard. As you will be aware, the screen has two lines and each line can display up to 16 letters, numbers or symbols (such as the ‘+’ and ‘~’ signs). These are called characters, and we shall refer to them as such from now on. If the screen is not large enough to display all the information at one time, the Office arranges for the display to scroll from side to side or up and down, allowing us to view the whole message. It is rather like a mask moving over the page of a book, revealing new information as it travels around. We can control the scrolling process by using the special keys marked with arrows on the keyboard: they are called the cursor keys. Generally speaking, the Office lets you know when it is expecting you to communicate with it — that is, enter something at the keyboard - by placing a marker or cursor on the screen. The keyboard can be switched to produce ‘letters’ (i.e. — the characters on the keys), or ‘numbers’ (the characters above the keys). When the keyboard is switched to ‘letters’, the cursor will be a flashing block and an underline character. When the keyboard is switched to ‘numbers’ the cursor will be just the underline character — no flashing block. 1.1 The Warehouse Concept Thus the screen display indicates what type of entry you will be making from the keyboard, and the Office knows exactly what character you want when you press a particular key. The keyboard is discussed in more detail at the beginning of Part 2. Try the following. Switch on your Organiser. The screen display will show a range of options: this is called a ‘Menu’. Now press the SHIFT and NUM keys at the same time to switch the keyboard to provide number inputs. The cursor will change to just the ‘underline’ character ~no flashing block. ; Now as you probably know, you can usually select an item on the Menu by simply pressing the key corresponding to the first letter of that item — as an alternative to using the cursor keys to move the cursor to the required item, then pressing the EXE key (see Chapter 2.2). So now try to switch Organiser off by pressing the O key. It doesn’t work. The Office is expecting you to type a number — or one of the characters printed above the keys. So when you pressed the O key, the message received by the Office was 4 — the number printed above the O key. At this stage of the game, the Office knows what to do if the first letter of any of the words on its Menu is typed in, but it doesn’t know what to do about numbers. So it does nothing ~ except sit and wait. The only way you can select any item from the Menu while the keyboard is set for numbers is to use the cursor keys to select the item and then press EXE. , So, to switch off now, either select OFF on the Menu by using the cursor keys and then press EXE, or press the SHIFT and NUM keys at the same time, to reselect letter inputs, then press the O key. Special duty departments There are several other departments in our warehouse for handling special ‘duties’. For example, the Office needs a way to communic- ate with us audibly, for those occasions when we have ‘booked’ an Alarm call. There is, therefore, a sound system built in. We can gain access to the sound system — not from the keyboard, but through a program — to control the duration and tone of the sounds produced for our own purposes. This particular aspect of Organiser II is dealt with in detail in Chapter 3.12. The other ‘special’ departments need not concern us at this stage: they will be discussed as and when the need arises. Summary That completes our preliminary look at the construction of Organ- iser II. To sum up, it has: . a) Numerous memory boxes, which hold the information Organ- iser IT needs to perform and to remember things for us. b) A busy Office or Central Processor Unit which is in charge of everything that goes on inside the Organiser II. c) A keyboard to allow us to communicate our requirements to the Office. How Organiser works ad) A screen, so that we can see what we are doing at the keyboard, and so that the Office can communicate with us. e) Special duty departments ~ such as the sound system — which help the Office to perform. f) A power supply, with a small reservoir of power to enable the battery to be changed without losing valuable information. We will now examine one of the important components — the memory boxes — ina little more detail. 1.2 THE MEMORY BOXES More than one type Within the Organiser II there are two different types of memory box. In the Datapaks and the Program Packs, there is a third type. If you use Datapaks, it is important to understand the difference between the type of memory they use and the memories inside the Organiser, in order to save an unnecessary waste of memory space when programming or saving information. This Chapter discusses the three types of memory box, and then examines in more detail exactly what goes into them. ‘Look-in’ only boxes The first and most extensively used type of box inside Organiser II can be looked into, to see what it contains, and that is all. Its contents cannot be changed or removed. Even if the battery is disconnected for long periods, the contents of look-in only boxes remain intact. This type of memory box is used to contain information for the running of Organiser II. The Office looks into these boxes, in the main, for the instructions it needs to provide the Diary, Alarms, Clock, Calendar, Record-keeping and Calculator applications, and also for the information it needs to provide the programming facilities. There are 32,768 boxes of the /ook-in only type in the Organiser II — an indication of just how much memory is needed to provide all these facilties. Obviously this part of memory cannot be used by us directly: the Office uses it on our behalf whenever we want the Organiser to do something for us. The process of looking into a box to see what is there is often called reading, and consequently these boxes are known collect- ively as Read Only Memory or ROM for short. You have probably heard the word before. As a matter of interest, the boxes for the Read Only Memory in Organiser II have addresses from 32,768 to 65,535. 7 How Organiser works ‘Put-in, look-in and change’ boxes We can not only look into this type of memory box, we can also put information in. If there is an item of information already in the box when something new is put in, then the original item is lost. It is rather like a cassette tape: when a new recording is made on on it, what was there before is erased. Also, like a cassette tape, this type of box can be ‘emptied’ so that there is virtually nothing in it at all —its contents are erased. This type of box is used to store our information on a ‘temporary’ basis, although ‘temporary’ can mean as long as we like. The computer term for a collection of these boxes is Random Access Memory or RAM for short. That’s because you can look in, put in and change the contents of each box ‘at random’ or at will. Within the CM Model of Organiser II there are 8,192 such boxes, while in the XP Model there are 16,384. Most of these boxes are available just for your own use — to keep your records, your Diary information and so on. However, the Office needs some of the boxes for its own ‘housekeeping’ purposes, because it too needs to save information on a ‘temporary’ basis. It cannot use the ROM /ook-in only memory for that. The small snag with this type of memory box is that it needs a power supply to keep it ‘active’. No power supply, no RAM memory. That’s why Organiser II has been provided with a small reservoir of power for when you change batteries — to give you adequate time to make the change without losing all your valuable information. For both Models of Organiser II, the first address of these memory boxes is 8,192. The Office also has another small chunk of RAM all to itself, at addresses from 64 to 255. It will look into the box at address 164, for example, to find out whether the internal sound system should be ‘muted’ — i.e. should it make a noise for an Alarm call or not. There may be times when you don’t want your Organiser to make a noise - when you're at a meeting or the theatre, for example — and by altering the information at this address, you can make your wishes known. (See your Handbook, Page 151). Generally speaking, the boxes at the addresses from 64 to 255 should be used only when you wish to change the way that Organiser II operates - and even then, they should be used with great caution. In any event, they can be accessed only by writing a program. In practice, you need not worry about the addresses of the memory boxes at all until you become an experienced programmer. Organiser II knows exactly where to put information on your behalf, and it can tell you where that information is, when you really need to know. The important thing is that it knows where the information is, and can find it again the moment that you need it. Comforting thought. 1.2 The Memory Boxes ‘Put-in, look-in, lock-up’ boxes This is the type of memory box to be found in the Datapaks. It combines some of the features of the two memory boxes discussed so far. You can put information in one of these memory boxes, and you can look in to see what is there. But once the information is in, it cannot be changed by Organiser II. So to all intents and purposes, once the information has been put in, it is there for good. Well, almost for good. If the information that you put into this memory becomes out of date — a friend’s address or telephone number changes, for example ~ then when you enter the new, correct information, you lock up the boxes with the old information in, and the new information goes into a new set of boxes. Once the boxes are locked up, you cannot look into them any more. So what is the benefit of having this type of memory? Quite simply, it doesn’t need a power supply. The information the boxes contain remains good and true, even when the Datapak is removed from Organiser II. This means that there is no limit to the amount of memory you can plug into your Organiser. You could, for example, keep all your personal addresses on one Datapak, and all your business contacts on another. A third could contain details of your stamp or record collection, or your own proven programs. You simply plug in the appropriate Datapak when you want access to the information it contains. A question arises. If this type of memory gradually gets used up as up-to-date information replaces old, doesn’t there come a time when the good information occupies only a comparatively small number of boxes but, because of all the locked-up boxes, there’s no room for more information? Yes. But all is not lost. The good information can be transferred to a fresh Datapak (or even into the Organiser II’s RAM memory, if there's room), and the old Datapak can then be ‘wiped’ absolutely clean of everything that it contains, so that it can be used again as good as new. This ‘wiping clean’ process is achieved by exposing the Datapak to ultra-violet light (with its protective label) removed) for thirty minutes or so. A special unit is available for performing this operation: if your dealer doesn't have one, then Psion will do it for you for a nominal handling charge. When you plug in a brand new or ‘cleaned up’ Datapak, Organ- iser II knows immediately that it is completely blank and auto- matically prepares it to receive information — a process called sizing. This simply means organising the Datapak so that the information can be put in correctly on your behalf, and it takes only a few moments. You will see a message on the screen to the effect that sizing is being undertaken. In computer language, the type of memory we have just been 9 How Organiser works discussing is called Erasable Programmable Read Only Memory, or EPROM for short. The type of memory to be found in the Program Packs is virtually the same, but of course, you cannot ‘lock-up’ the boxes: there would be nothing to gain if you could, only everything to lose. The putting-in — of program information — has already been done for you. So as far as you are concerned, a Program Pack effectively contains look-in boxes only. What goes into the boxes As far as we are concerned, all three types of memory box store information the same way. It would be nice to think that one memory box contains a specific ‘chunk’ of information, such as an address or a telephone number. It doesn’t. It doesn’t even contain one ‘word’. All that any memory box in Organiser II can hold is a number between 0 and 255. Moreover that number, whatever it is, can represent an instruction or part of an instruction, it can represent a character such as the letter ‘A’ or the figure ‘3’, or it can represent part of a value — that is, an actual number which is to be used for mathematical operations such as adding, subtracting, multiplying, dividing and so on. (The reason why computers need to know the difference between numbers as characters and numbers as values will be made clear later on). This raises several questions: how can a number represent an instruction, a character or a value — and how does the Organiser know the difference (numbers are, after all, just numbers)? And why is 255 the largest number that a memory box can hold? Understanding the answers to these questions is fairly important when learning to program the Organiser II. The rest of this Chapter is devoted therefore to providing the answers, starting with why the number stored in any one of Organiser’s memory boxes cannot be higher than 255. Computers count differently One of the most difficult things for many people to get to grips with during their introduction to computers is the fact that computers have a different way of ‘counting’. In our normal, everyday life, we use the decimal system of counting. That simply means we have ten ‘ different numbers to count with — 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Computers have only two numbers to count with. This is because it is far easier to have devices with two states than it is to have devices with ten states. Take an ordinary switch, for example. This can be off, or it can be on. If we say that when the switch is off it represents the value ‘0’, and when it is on it 10 1.2 The Memory Boxes represents the value ‘1’, we have a simple way of representing the values 0 and 1; for ‘0’, we can set the switch to off, and for ‘1’ we can set the switch on. Not very much use. However, we can now add a second switch. We can say that when this second switch is off it represents ‘0’, and when it is on it represents ‘2’. Now, by using both switches, we can represent the the values 0, 1, 2 and 3. Thus: The ‘2’ switch The ‘1’ switch OFF (=0) OFF (=0) represents 0 OFF (=0) ON (=1) represents 1 ON (= 2) OFF (=0) represents 2 ON (= 2) ON (=1) represents 2+1= 3 Without being too boring, we can add yet a third switch, to represent ‘0’ when it is off, and ‘4’ when it is on. Now, with these three switches, we can represent numbers from ‘0’ to ‘7’. For numbers ‘0’ to ‘3’, this new switch would be off. Then, for numbers ‘4’ to ‘7’: ‘4’ switch’2’ switch’]’ switch ON (=4) OFF OFF represents 4 ON (=4) OFF ON (=1) represents 4+ 1= 5 ON (=4) ON(=2) OFF represents 4+ 2= 6 ON (=4) ON(=2) ON (=1) represents4+2+1= 7 We can continue, the same way, until we have eight switches, representing the numbers 128, 64, 32, 16, 8, 4, 2, and 1 respectively when they are on. With all of the switches on, the number they represent is 255 (i.e 128, 64, 32, 16, 8, 4, 2 and 1 all added together). By setting these switches on or off in different combinations, we can represent all the numbers between 0 and 255. (Congratulations. You have just mastered the basics of the Binary Code!). As you will gather, one of the Organiser II’s memory boxes effect- ively contains eight ‘switches’: the way the ‘switches’ are set determines the number contained in the box. But why use only eight switches — why not use ten, say, to allow us to represent even higher numbers? Just as we have seen how binary is a convenient counting system for computers to use, so eight is also a convenient number in computer technology. In larger computer systems, the memory boxes have 16 or 32 ‘switches’ — always multiples of eight. Each of the ‘switches’ in one of our memory boxes is representing a Binary digit, or Bit for short. Hence the Organiser II is called an eight-Bit machine. The block of eight ‘switches’ in a memory box are called a byte. 11 How Organiser works (Taken together, the first four ‘switches’ and the last four ‘switches’ are each called a nibble. Don't ask!). = As you know, the abbreviation ‘k’ (short for ‘kilo’) usually stands for 1000. In the world of computers, ‘k’ actually stands for 1024. So when you see that a computer has a memory of 8kbytes, it means it has roughly 8000 memory boxes, or, to be precise, it has 8,192 (8x1024) memory boxes. We need not delve any deeper into the way computers count (sighs of relief). Storing ‘characters’ In Chapter 1.1, we saw that within Organiser II there are several ‘Special Departments’. One of these departments is effectively a library of patterns. Each pattern in the library is different, and defines the ‘shape’ of a character, as it appears on the screen. Each pattern is identified by a number: pattern number 65, for example, defines the shape for the capital or upper-case letter ‘A’, pattern 97 is for the small or lower-case letter ‘a’, and pattern 51 defines the figure ‘3’. (The Organiser cannot use this pattern number for calculations —- and so the value ‘3’ has to be stored differently). Within Organiser II's ‘library’ there are 192 predefined patterns, numbered from 32 to 127 and from 160 to 255 inclusively. When the number stored inside a memory box represents a character, the Office in effect sends a messenger off to the library to look up the corresponding pattern for printing on the screen. The keyboard of Organiser II allows you to access 79 of these patterns: the upper and lower-case letters, as printed on the keys, the numbers and symbols, as printed above the keys, and SPACE . which is really just a blank pattern. When you press a key, it actually passes a number to the Office. If the information you are entering at the keyboard is to appear on the screen, then the Office sends off the messenger to look up the corresponding pattern, and that pattern is then reproduced on the screen in the appropriate lace. ‘ . This happens, for example, when you are entering information that you wish to SAVE as a record. If you'd like to see what number is associated with each key - and hence with each pattern - do the following: a) Switch on your Organiser II, and select CALC. ‘ : b) Press the SHIFT and NUM keys together, to select letter’ inputs. (Your Organiser automatically chooses ‘number’ inputs when you select CALC), . c) Type fh the word GET, and then press the EXE key. (GET" is one of the Organiser II's programming words which we will come to later. It tells the Office to send a messenger to the keyboard to wait for a key to be pressed, and then to report back the corresponding pattern number. In this instance, it reports the number to the screen). 12 1.2 The Memory Boxes d) Press any key. The number corresponding to the pattern for the key pressed will appear on the screen. For example, if your Organiser is set for CAP letters, pressing the A key will cause the number ‘65’ to be printed on the screen. If it is set for lower-case letters, pressing the A key will cause the number 97 to be printed on the screen. If you set the keyboard for NUMbers, pressing the A key will cause the number ‘60’ to be printed on the screen — this being the number for the ‘<‘ pattern. e) To try out another key, press EXE, which takes you back to CALC:GET, then press EXE again, to execute the instruction, then press the key you wish to see the pattern number for. If instead of pressing one of the ‘character’ keys you press one of the ‘control’ keys (one of the keys marked with an arrow, for example) you will still get a number displayed on the screen. These ‘control’ key numbers have a special and useful significance when you are writing your own programs: they enable your program to detect, for example, when a specific ‘control key has been pressed, When you are ready to switch off, simply press the CLEAR/ON key two or three times, to return to the main Menu, then press O, or select OFF using the cursor keys and press EXE, Earlier, it was stated that there are patterns associated with every number from 32 (the SPACE or blank pattern) to 127 and from 160 to 255, But you can ‘get at’ only 79 of these directly from the keyboard. You can get any of the others printed on the screen through a program. The full set of characters is shown in the Appendix. What about patterns for the numbers from 0 to 31, and from 128 to 159? Part of the ‘library’ is allocated to you, so that you can define your own patterns. You can create up to eight patterns for your own use ~ and these have numbers from 0 to 7. You need a program to enter the patterns you require. But note that the patterns you define are lost whenever the Organiser II is switched off. So if you want to use your own patterns in one of your programs, you must arrange for those patterns to be defined as part of the program, (to