The Thought Processor MiCROL SPECTRUM THE DATA BASE 48k CASSETTE SYSTEM Contents The Database 3 Applications 3 Getting Started 3 Entering Data 4 The display 4 Feel free to experiment 5 Introductory example 5 The commands 7 User configuration 12 Summary of commands 14 - 1 - Copyright (c) 1982 by MiCROL. All rights reserved. See cassette copyright notice for further information. Published and printed in England. MiCROL (UK Mail Order) 38 Burleigh Street Cambridge CB1 1DG Subject to statutory limitation MiCROL accepts no liability for loss, loss of profit, or consequential damage arising from the use of THE DATABASE or from information contained in this manual. It is the purchaser's responsibility to ensure suitability for purchase. - 2 - The Database A database is a way of storing information so that you can easily access it, add to it, and change it. The Database is a simple-to-use database-handling program which gives you all the tools you need to handle data. Unlike traditional database programs, The Database allows you to store information in any format you choose - there is no initial process of record and field definition. You can just type information in, and it appears on the screen. Powerful facilities like sorting and searching are available, but these more complicated features only appear when you need them: at first, you need only learn a few easy commands to create your database. Applications You can type completely free-form information into The Database, so there are no limits to what sort of information you can store. If you wish, you can structure your data into paragraphs, but this is optional unless you want to sort paragraphs into alphabetical order. You can use the numeric capabilities of The Database for simple business models and forecasts, or for home finance. A file - the information stored in the computer's memory - is divided into documents, and each document can do a completely different job. For example, you could create a file called 'personal' which contained a document called 'address book' with the names, addresses and telephone numbers of all your friends and relations, sorted by name; another document called 'memo-pad' with notes of appointments and meetings at work; and another called 'bank balance' with calculated lines analysing your current financial state. The Database can be used in small businesses for stock control, mailing lists, customer account records, and so on: in fact, for almost anything needing data storage combined with simple calculations. Getting started The Database is recorded on both sides of the tape. To load it, use the command 'LOAD "database"' or just 'LOAD ""'. The program will run automatically when it has loaded, and you will be asked 'filename: '. The name you give will be used for saving and loading any file you create in this session. It should be between one and ten characters long. When you have entered the filename you will be asked 'document title: '. This requires a word of explanation. The file is all the information you have in - 3 - memory at present. A file is divided into documents, and there must be at least one document in a file. You have just created a new file by loading The Database, and you are being asked for the name of the first document in the file. A document name can be up to 31 characters long. For example, typical files might contain documents called 'Mailing List', 'Stock Ledger', 'Part Codes', 'Memoranda' etc. For now, just type something like 'test'. Entering data To enter data, press the ENTER key. A flashing input cursor will appear in the bottom left corner. You can now enter as many lines of data as you like. Each line may contain up to 31 characters. When you want to stop entering data, just press ENTER right after the cursor (that is, enter a blank line). Try this out by typing the letters of the alphabet from A to Z, one letter on each line. You should notice two things: (i) there is a screen cursor - an underline (_) at the left hand end of the line - which shows you which line you are 'on'; and (ii) when you have filled up the screen, the next line you enter will cause the display to be readjusted. You can enter data where you like in the document. Move the cursor up a few lines by pressing the 7 key (unshifted) and enter a new line. There are various ways of moving around the document. The simplest are the unshifted up and down arrow keys, which move the cursor up or down one line. To move 10 lines in one go, use CAPS SHIFT with these two keys. The unshifted left and right arrow keys move you to the start and end of the document respectively. The display When you typed in the document title you reached the main part of The Database. The screen has a bright line at the top consisting of an asterisk (*) followed by the document title. The asterisk is not part of the title - it is just there as a control code to indicate to the program that this line is a title and not a line of data. The rest of the screen will always show the local area of the current document, and has a cursor (_) - which indicates the current line. The first character of each line is reserved for control characters, of which there are three major ones. An asterisk (*) means 'this line is a document title'. A plus sign (+) means 'this line is the start of a paragraph'. A minus sign (-) means 'eyes-only line: appears on the screen but is not usually printed on the printer'. In addition to these three control codes, the letters a-h and n can - 4 - appear in this position. They are calculation references, and are used by the numeric functions of The Database (see the N, C and K commands, below). The bottom of the screen is normally blank but at times various messages appear here. You can see this by pressing the SPACE key, which will display a message telling you how much space is left in the file. These messages will stay for a short time, then disappear. They also disappear as soon as you press a key. Feel free to experiment Press any key you like while you familiarise yourself with The Database, You will not normally be able to harm your data or the program. If you press a key which is not a valid command there will be a short bleep, and nothing else will happen. Some commands, like S (sort) require confirmation: a message like "type 'yes' to sort: " appears. Just press ENTER or type anything other than 'yes' to escape. In fact, you can escape from any command that asks a question by pressing ENTER. If you manage to crash The Database by, for instance, putting a calculation line in that doesn't make sense (in this case you will get the error message 'Nonsense in Basic') you can always restart with no loss of data by typing 'GO TO rs'. 'rs' stands for ReStart. Introductory example: a telephone directory. A personal telephone directory is about the simplest useful database application. Starting off by creating a new document called 'telephone directory'. To do this, make sure that you are not in the middle of entering text, then press the A key, which means 'add a new document to the file'. Alternatively, load The Database afresh, or stop it and type RUN (use RUN with care: it wipes out all your existing data). Type 'telephone directory' in answer to the question 'document title: '. In its simplest form, a telephone directory entry has two parts: a name and a number. Using the ENTER command, type in something like this: +Soap, Joe and Mary 01-653 8945 +Bloggs, Fred and Arabella 061-347 8490 +Jeffreys, Judge 0635 204432 - 5 - Notice the plus sign at the beginning of every 'name' line. This indicates the start of a paragraph. If you type a plus sign as the first character of a line, it will be placed in the first position on the line, which is reserved for control codes. Paragraphs aren't compulsory, but if you set up your document as a series of equal-length paragraphs you will be able to sort them into alphabetical order if necessary. If you make a mistake and only notice it after you have pressed ENTER, press ENTER again, then press the D key. This deletes the current line. When you have done this press ENTER again to get back into text-entry mode. Type a few more names in, so that the document spills over on to the next page. This will give you an idea of what to expect when the screen is automatically redisplayed when you go off the top or bottom. If you have kept to the format shown above, try out the S (sort) command, Press S, then type 'yes' to confirm that you really want to sort (the confirmation should prevent accidents caused by pressing the wrong key). As the sorting progresses, messages will appear at the bottom of the screen saying things like 'sorting blocks of 12'. Don't worry about this: it's just to let you know that something is happening. When the sort has finished The Database will bleep twice, and the document will be redisplayed, sorted into alphabetical order by comparing the first line of each paragraph. Press I. This is the 'index' command. It gives you a list of the documents in the file, with their sizes. It's also a handy way of finding out the name of the current file, if you've forgotten. Find a spare cassette and try out the $ (save) command. This saves the current file, using the name you gave when you created it. The time it takes to save a file depends on its length: a hundred-line file will take fifteen seconds or so. Now stop The Database by pressing BREAK, then type RUN. Type '1' then ENTER in response to the 'filename' and 'document title' questions. This is a quick way of creating a dummy file which will be overwritten when you load a file from tape. Press £ (load), and specify the filename you used for the document you saved. Rewind the tape and play it through. After loading, you will be 'on' the top line of the first document in the file. Keep experimenting with the commands. If you have a ZX printer, try out the P (print) command, which is explained below. - 6 - The commands ARROW KEYS: 6 and 7 (unshifted) move the cursor down one line and up one line respectively, Shifted, these keys move the cursor ten lines. 5 and 8 (left and right arrow, unshifted) move to the beginning and end of the document respectively. 1 and 0: move to neighbouring document. 1 moves you to the title line of the preceding document in the file. 0 moves you to the title line of the following document in the file. A: add document. Asks you for a 'new document title'. Pressing ENTER escapes from the A command. A new document, empty apart from a title line, is placed in its correctly sorted position among the existing documents. This means that unless you edit their titles, the documents in a given file will always be sorted into alphabetic and numeric order. When you use the A command the cursor is moved to the title line of the new document. C: calculate current document. The calculation lines in the current document will be evaluated, and the results placed on at the right hand end of these lines. Calculation lines have one of the letters a,b,c,d,e,f,g,h, or n at the beginning of the line. See the N (enter number or calculation) command below. BREAK: you can stop The Database by pressing the usual Spectrum BREAK key (CAPS-SHIFT and SPACE). This is useful if you want to change one of the user configuration variables (see 'User configuration' below): you can restart The Database by typing 'GO TO rs'. Pressing BREAK, then typing RUN, is the way to clear all the data from the file and start again. D: delete the current line. The current line will be removed and the gap closed up. See the Y command below. ENTER: enter a line or several lines of data. Every line you enter is placed in the document at the cursor position - in fact, below the line with the cursor on, but since the cursor is at the bottom edge of the line, it can be thought of as indicating a point between two lines. Every time you enter a line of data, you will be given the opportunity to enter another one, To stop entering lines, press ENTER as soon as the inverse L appears: i.e. enter a line with nothing in. This will return you to the normal command level. - 7 - F: find. First you will be asked 'find:'. Type in the sequence of characters you are looking for, The question 'options:' will appear: press ENTER for a straightforward search of the current document. If you enter no options, the scope of the search will be the current document; the start of the search will be the beginning of the document (or file, if the 'a' option is used); and all character positions will be searched. However, you may type in a string of characters which specify non-standard options. 'a' means 'search all documents, not just the current one'. 'h' means 'start here, not at the beginning'/ 's' means 'search only at the start of each line'. These options can be combined freely, and given in any order: 'as' or 'sa' entered in response to 'options: ' 'means 'search all documents, looking only at the beginning of each line.' There are two special options, AND (symbol-shift Y) and OR (symbol-shift U). If you use either of these options, you will be asked for another sequence of characters to search for. AND searches for both strings within the same paragraph, or within 11 lines if there are no paragraphs or paragraphs are larger. OR searches for the first occurrence of one of the strings. AND and OR can be combined with the other three options, but not with each other. If you do this AND takes precedence. A successful search will result in the cursor being moved to the line containing the target of the search. If the search fails, an appropriate message appears and the cursor does not move. The 'find' command makes no distinction between capitals and small letters. Sometimes you will want to find something without knowing exactly how it is spelt. For example, you might want to find the first occurrence of either 'practise' or 'practice'. When you answer the 'find: ' question, type a question mark for any character you are unsure of: in this case, type 'practi?e'. The question mark is known as the wild card character, You can have as many question marks as you like in one 'find' string. A question mark will match any character. G: go to document. Asks you for a document title, then moves the cursor to the top line of that document (or the first of that name, if several have the same name). Note that you need not type the full name of the document: only enough to identify it from the rest. 'Tel' is enough to get you to 'Telephone directory' if there are no preceding documents starting with 'Tel'. - 8 - I: Index. Displays a list of all the documents in the current file, with their lengths. The name of the file itself is given in the heading. E: calculate the current line, if it is a 'numeric' line. Like C, but works on the current line only. £: load file from tape. Ask you for the name of the file to load, and searches for a file created by the $ (save) command. If the file is found, the entire current file (all the documents in memory) is deleted and replaced by the new file. Use the I (index) command to find out the names of the new file and its documents. If you load The Database and wish to start immediately working on a previously-created file, answer the 'filename: ' and 'document title: ' questions with dummy names - it is easiest to press '1' in response to both questions, then use the £ command straight afterwards. M: memory. Remember the current cursor position, for retrieval by the X command (see below). N: enter numeric or calculated line. This command acts just like the ENTER command, in that you go on entering lines until you stop the process by entering nothing at all. A prompt, 'calculation: ' is printed each time. A calculation line has to conform to a certain pattern. The first character must be one of the special calculation reference letters: a,b,c,d,e,f,g, h and n. These letters identify lines so that they can be used in calculations. The letter n is slightly different: it can only be used as a result, or to refer to the result of the last calculated line. This is explained in more detail below. The next part of the calculation line is an optional label, such as 'price', 'inflation rate', 'salary' or 'April'. This must be followed by an equals sign, then lastly a number or calculation. A series of typical calculation lines is: a Price = 62.95 b Sales = 4883 c Revenue = a*b Notice that the label is optional: the third line could have been written 'c=a*b'. To calculate the result of a series of lines, use the C (calculate document) command. If you use this command with the example above, the numbers 62.95, 4883 and 307384.85 will appear at the right hand end of the three lines. Calculations can be as complicated as need be, as long as they fit on one line, and are written just like calculations in BASIC. You can use functions like SIN, INT and SQR but this is - 9 - not recommended because it causes problems with the display. It is safest to stick to addition, multiplication, subtraction, division, exponentiation (raising to a power) and the use of brackets. If you use an expression which cannot be worked out, like 'a+*b', or divide by zero, The Database will crash with a BASIC error message when you use the C or K command to calculate it. Just restart the program by typing 'GO TO rs' and edit the offending line. When you create a file, The Database assumes you want numeric results to be rounded to two decimal places. This can be altered: see the section entitled 'User configuration' below. There are eight ordinary calculation references, the letters a to h, but you can actually have as many calculated lines in the document as you like. If the reference 'c' is referred to by a calculation, the last 'c' that was calculated is used. Usually this will be the last 'c' line preceding the line which refers to it. Another way to use more than eight calculations is to use the 'n' reference. 'n' always refers to the last result calculated. You can either use 'n' lines for calculations which are only results, and are not referred to by other calculations, or you can use a series of 'n' lines, each referring to the last. For example, to set up a projection of the inflation rate, create the following lines: a inflation rate = 1.08 b base = 100 n=n*a Create, say, 20 copies of the 'n' line by deleting it using the D command, then retrieving it 20 times using the Y ('yank') command (see below). Now press C to calculate, and you will see the effect of twenty years inflation at 8 percent on a base index of 100. P: print document. This command prints the document starting from the cursor position, so if you want to print the entire document, move the cursor to the top line using the 5 key. To stop printing, press any key. The control codes in the left hand column are not printed, but are interpreted in various ways. A plus sign will be printed as a blank line, giving a gap between paragraphs. In fact, you can set the number of lines between paragraphs to anything you like by changing the variable If: see 'User configuration' below. A minus sign normally indicates an 'eyes-only' line. This will only be printed if the variable eo is set to one. Again, see the 'User configuration' section. - 10 - Q: print the current line only. This has the same effect as the P command, but only prints one line. R: replace string. This command uses exactly the same prompts as the F (find) command (see above), but if the search is succesful you will be asked 'replace with:', and the target string will be replaced by whatever you type in. This makes it possible to edit lines without entirely deleting and retyping them. To delete a string, press ENTER in response to 'replace with:'. S: sort current document. When you press S, then confirm the command by typing 'yes', The Database will check whether all the paragraphs (marked by + signs at the beginning) are the same length. If they are not, a message will appear at the bottom of the screen saying 'paragraph different size' and the cursor will be placed on the first paragraph that is not the same size as first paragraph in the document. If there are no paragraph markers (plus signs at the left hand side) in the document, individual lines will be sorted: that is, the paragraph size will be taken to be one line. If the paragraphs are all the same size the sort will go ahead, and a series of messages of the type 'sorting blocks of 4' will be displayed at the bottom of the screen. This should reassure you that something is happening: a sort can take quite a long time. Documents of upt to a couple of hundred lines, in paragraphs of two or three lines each, will only take a few minutes, but if you wish to sort a document of 999 individual lines, be prepared to wait about forty minutes. $: save current file. The current file will be saved to tape, using the file name you gave when you created it. Only the used part of the file is saved, so the time it takes will vary. A full file of a thousand lines takes about two minutes to save. SPACE: space left. Pressing the space key will display a message saying how many lines are left in the current file. The current file can contain a maximum of a thousand lines, so this number will always be one thousand minus the combined lengths of all the documents, given by the I (index) command. T: type lines on the ZX printer. This simple command prints whatever you enter on the printer. It allows you to add headings, footnotes and comments to the reports you produce using the P and Q commands. You may type as many lines as you like: go back to the main command level by pressing ENTER as soon as the 'type:' prompt appears. - 11 - X: exchange memory and current line. See the M (memory) command above. If you have set a memory pointer using the M command, you can jump to the remembered line by pressing X. You cannot use the X command unless (i) you have set the memory using the M command and (ii) the remembered line is still within the bounds of the file (i.e. you have not moved it out of range by deleting lines). The old current line becomes the memory line, so you can jump back by pressing X again. Y: 'yank' (retrieve) deleted line. The last line deleted can be retrieved and automatically reinserted by pressing Y. This not only enables you to recover from error, but allows you to move a line by deleting it and reinserting it somewhere else, and copy a line by deleting it, then retrieving it more than once, perhaps in several different places. Z: 'zap' - delete entire document. This command will not work unless the variable de (delete enable) is set to the value one. See 'User configuration' below. If deletion is enabled, The Database asks for confirmation, then deletes the current document and closes up the surrounding documents. If the current document was the last document in the file The Database is reRUN: you will have to supply a new file name. User Configuration There are a number of variables which you can change to get The Database to operate in the best way for your application. These are all set up in line 11. If you edit this line of the program you can create a copy of The Database tailored to your preferences, and save it on a fresh tape using the command 'SAVE "database" LINE 1'. Alternatively, you can change these options for the duration of the session by dropping out of The Database by pressing BREAK, assigning a value in the usual way - e.g. 'If=3' - then restarting the program by typing 'GOTO rs'. The variables on line 11 are: ei: echo input. If ei is one, when you type in a line it will be printed on the ZX printer, if this is attached. If ei is zero input is not echoed to the printer. This feature allows you to produce a report of any additions to the database, as you type them in, You could use the T (type) command to print a heading giving the date: after the session you would have a dated archive or audit which you could keep for future reference. eo: print 'eyes-only' lines. If eo is one, lines with the - 12 - 'eyes-only' code, a minus-sign at the beginning, are printed normally. If eo is zero, eyes-only lines cannot be printed. This allows you to set up a mailing list including an eyes-only line for the telephone number, the reason being that you would not want the telephone number to appear if you used the P command to print labels to paste on envelopes. If: number of linefeeds between paragraphs. When you use the P or Q command and a line starting with + is encountered, If blank lines are sent to the printer. This starts off at one, but you can set it to anything you like, including zero. de: deletion enable - allows you to delete documents using the Z ('zap') command. If de is one, the Z command is allowed. If de is zero, the Z command is not allowed: the message 'deletion disabled' appears if you press Z. For safety's sake de starts off at zero. rd: report delay. You will notice that reports stay on the screen for about three seconds unless you press a key, in which case they disappear. This three-second delay is caused by rd being set to 150: the unit is a fiftieth of a second. You can set this to anything you like, but note that a value of zero means that the report will stay on the screen for ever, or until you press a key. ro: rounding. If ro is one, the displayed results of any calculated lines will be rounded to the number of places specified by the variable pl. This only affects the display: the numbers are held internally to the full precision allowed by BASIC. If ro is zero, calculated results are not rounded. The Database starts up with rounding switched on and two decimal places. pl: decimal places for rounding. pl contains the number of decimal places used when calculated results are rounded (see the note on ro above). pl starts off at two. Other useful values are zero (for integers), one, three and four. Take care not to set pl too large: the rounding method involves multiplying the number to be rounded by ten to the power of pl, so it is possible to cause a 'Number too big' error. If this happens, change pl to something lower, then type 'GOTO rs@ to restart. - 13 - Summary of commands ARROW KEYS: 7 and 6 (unshifted) move up and down one line, or (shifted) move up and down ten lines. 5 and 8 (unshifted) move to the beginning and end of the document. 1 and 0: move to preceding and next document respectively. A: Add a document to the file. The new document is placed in alphabetic order with existing documents. BREAK: stop The Database. 'GO TO rs' restarts. C: calculate current document. D: delete the current line and close up the gap. See Y. ENTER: enter a line or lines of data at the cursor position. F: find string. If you press ENTER in response to 'options:', F searches all possible positions in the current document. See 'The commands' for details of options. G: go to document. I: index. Lists documents in current file. K: calculate the current line. £: load file from tape. If the load is successful, all documents in previous file are deleted. M: memory. Remembers current cursor position. See X. N: enter numeric line. See 'The commands' for details. P: print current document, starting at current line. Press any key to stop printing. Q: print the current line. R: replace string. Like F (find) but asks 'replace with:' if the search succeeds. S: sort current document. Sorts paragraphs into alphabetic order, comparing first lines. Only works if all paragraphs are the same length, or document contains no paragraph markers. $: save file on tape, using filename specified when the file was created. SPACE: display number of lines left for data. T: type line or lines on the printer. X: exchange current position with position remembered by M command. Y: yank (retrieve) last line deleted. Z: zap (delete) entire current document. Only works if enabled (see 'User configuration'). - 14 - THE THOUGHT PROCESSOR MiCROL