PASCAL 64. "The" Pascal Compiler for the Commodore 64. A Data Becker Product. >AbacusiII Software P.O. BOX 7211 GRAND RAPIDS, MICK 49510

Size: px
Start display at page:

Download "PASCAL 64. "The" Pascal Compiler for the Commodore 64. A Data Becker Product. >AbacusiII Software P.O. BOX 7211 GRAND RAPIDS, MICK 49510"

Transcription

1

2 PASCAL 64 "The" Pasal Compiler for the Commodore 64 A Data Beker Produt >AbausiII Software P.O. BOX 7211 GRAND RAPIDS, MICK

3 COPYRIGHT NOTICE ABACUS Software makes this pakage available for use on a single omputer only. It is unlawful to opy any portion of this softare pakage onto any medium for any purpose other than bakup. It is unlawful to give away or resell opies of any part of this pakage. Any unauthorized distribution of this produt deprives the authors of their deserved royalties. For use on multiple omputers, please ontat ABACUS Software to make suh arrangements. WARRANTY ABACUS Software makes no warranties, expressed or implied as to the fitness of this software produt for any partiular purpose. In no event will ABACUS Software be liable for onsequential damages. ABACUS Software will replae any opy of the software whih is unreadable if returned within 30 days of purhase. Thereafter, there will be a nominal harge for replaement. First Printing, September 1984 Printed in U.S.A. Translated by Greg Dykema Copyright (C)1984 Data Beker, GmbH / Merowingerstr. 30 C 4000 Dusseldorf,W.Germany ^- Copyright(C)1984 Abaus Software, In. P.O. Box 7211 Grand Rapids, MI ISBN #

4 Prefae What is Pasal? Pasal is a Modern programming language developed by a Swiss professor (Dr. Niklaus Wirth) as a teahing language for strutured programming. It quikly beame popular for both teahing and ommerial appliations. Even among personal omputers, Pasal has beome a dominating language, loosening BASIC'S hold as the "standard" miroomputer langage. In many shools, Pasal is the standard for information proessing and strutured programming ourses. Now Pasal is available for the most popular of home omputers - the Commodore 64. What has lead to the tremendous popularity of this language? One of the primary reasons is the effiient program strutures of Pasal. A new method a programming, strutured programming, is built into Pasal. Strutured programs are far easier to understand and modify than unstrutured programs. Pasal eliminates many programming errors simply through its use of loal and global variable definitions in whih a loal variable name refers only to the program blok in whih it is delared. A additonal advantage is Pasal's omplex data strutures. In addition to the basi data types REAL, INTEGER, BOOLEAN, and CHAR data types, data fields (ARRAY), memory-optimized fields (PACKED ARRAY), harater strings (STRING), mathematial sets (SETS), data reord (RECORD), files (FILE), and pointers (POINTER) are all supported. These data types an be ombined as desired to form more omplex data strutures. With the help of pointer, one an onstrut linked list, staks, binary trees, and more. Pasal programs an be written with the built-in Commodore BASIC editor; you need not load in anything else or learn to use another editor. Pasal 64 ontains even more apabilites whih make use of the speial features of the Commodore 64. Proedures are inluded for working with high-resolution graphis and sprites. In addition, Pasal 64 allows you to make omplete and effiient use of the relative data management apabilities of your disk drive. Pasal 64 allows you to use strings of any desired length. Programs reated by Pasal 64 are times faster than equivalent programs written in BASIC, or even 30 times faster in some ases beause Pasal 64 reates atual mahine ode. Mahine language programs may also be ontrolled with PBEK, POKE, SYS, and other jpeial ommands. Pasal 64 an be used in onjuntion with the ASSEMBLER/MONITOR-64 software pakage available from ABACUS Software. Two programs an run onurrently useful for video games (sprite ontrol) or for ontrolling inter fae devies, for example. The possibilities whih Pasal 64 offers you are virtually limitless.

5 Table of ontents Chapter Operation of the Pasal 64 ompiler 1 Chapter 2 Chapter Organization of a Pasal program Domain of variables Defining a blok General syntax, Comments g Chapter Variable types Mathemati operations Program header Variable delarations Constant delarations Delaring user-defined data types Arithmeti expressions The Pasal assignment statement Input and Output Formatted numeri output 15 Chapter Control strutures Loop ontrol strutures The REPEAT statement The WHILE statement The FOR statement Conditional statements The IF statement The CASE statement The GOTO statement Using ontrol strutures Proedures and funtions Proedure delaration Calling a proedure Funtion delaration Reursion Exiting a proedure 27

6 Chapter Data strutures ARRAYS RECORDS Combining RECORDS and ARRAYs WITH statement Working with strings Subranges Length of strings Additional string operations String funtions Paked fields 37 Chapter FILEs Error hannel and file status Input/Output of data bloks Relative files Using relative files 43 Chapter SETs Representing sets Set operations Using sets 48 Chapter Dynami data strutures (linked lists) Using pointers Additional list strutures Combining data strutures 53 Chapter Graphis statements Initializing the graphis sreen Clearing the graphis sreen Setting a point - PLOT Erasing a point - UNPLOT The SPRITE statement The POKE statement Exeuting a mahine language program The high-speed mode - INTEGER Simultaneous exeution of two programs - INTERRUPT Run-time error messages 62 Chapter Symbol files for ASSEMBLER/MONITOR Jump to monitor 63

7 Chapter Drawing a line Ativating four-olor graphis Setting a point in multi-olor node 66 Chapter 13 Chapter Introdution to strutured programming A short overview of Pasal Data types Delarations Proedures and funtions Strutures Input and Output statements Other statements Assigments Arithmeti operations Predelared Funtions Aessing data strutures Predelared names Speial haraters for I/O BIBLIOGRAPHY 75

8 Abaus Software PASCAL-64 Chapter Operation of the Pasal 64 Compiler -1- Write your Pasal program as you are used to doing for BASIC programs. You aust use line numbers as you do for BASIC programs. Correting and inserting lines is done exatly as in BASIC. This means that you do not have to learn to use another editor, but the following exept ions must be noted: In Pasal, it is possible that a number must be the first item on a line. This happens with the CASE statement, for example. The BASIC editor is unable to distiguish this number from the the preeding line number, however, and assumes that it is an extension of it. In order to avoid this, a shifted spae an be used to separate this number from the line number. Whenever this line is edited, the shifted spae must be typed in again beause the LIST ommand prints a normal spae. It is better if you do not put a number and the beginning of a line, but use a semiolon instead, followed by a spae. This lone semiolon has no effet on the program and is read as a null statement. With the help of this trik, it is also possible to plae several spaes at the beginning of a line, making the the struture of the program learer. The two BASIC ommands REN and DATA affet the BASIC editor. Therefore they may not appear in any form in the program, not even as part of a variable name. -2- When you are finished writing the program, save it to your work diskette with SAVENprogram name**, 8. Do not under any irumstanes use the Pasal 64 distribution diskette or it may be destroyed. -3- To ompile the program, load the ompiler from the distribution diskette with LOAD'PASCAL 64",8 and start the program with HUN. When the ompiler has finished loading, take the Pasal 64 disk out of the drive and replae it with your work diskette. Should the ompiler fail to load properly, your disk drive may not have been initialized properly, although this happens only very rarely. Turn the omputer off and then bak on and enter the following line: OPEN 15,8,15,*I":CLOSE 15 After this, start again with the loader program. When the ompiler is orretly loaded, it will ask for the name of the program you wish to ompile, followed by the nesting depth of the program. The nesting depth is the - 1 -

9 Abaus Software PASCAL-64 number of loops or subroutines whih may be nested. The default value given by the ompiler must be inreased only for very deeply nested programs. Otherwise, simply press the RETURN key. Note: In BASIC, this value is limited to 9 for loops and 23 for subroutines. -4- Now the ompiled mahine language program will be writ ten to the work diskette. In its seond pass, the ompiler will display the line it is urrently working on in the top-most sreen line. -5- If the ompiler should find an unompilable line, it responds with COMPILE ERROR IN XXXX and a short desription of the error. Some error messages may be -somewhat misleading. For example, if a variable name is misspelled, the ompiler will respond with "Variable not delared," sine it has no way of knowing whether you forgot to delare a variable or if you simply misspelled it. To orret an error, reload your program with LOAD"program name",8; re-edit the program; SAVE it to disk, and ontinue with step 2 after orreting the error. -6- One the program has been ompiled suessfully, the ompiler will display a number representing the end of the program. Make note of this number, as we will need it later. If you want to ompile another Pasal program, press the "Y" key. The ompiler will automatially restart itself (the distribution diskette is not required). If you do not want to ompile another program, press any other key. -7- Load the loader from the distribution diskette with LOAD"LOADER",8 and start it with RUN 100. The program will ask for the program end (see point 6) and the program name and then loads the mahine language program from your work diskette. -8- The loader responds with "READY." and your Pasal program is ompleted. It an now be saved to diskette with SAVE; loaded in again with LOAD, or exeuted with RUN. When using the high-resolution graphis, the ompiler reserves 8K of memory for storing the graphis sreen. If you do not want to save this memory, enter SYS 3707 before the SAVE ommand. To later start suh a program, use SYS The file reated by the ompiler an be deleted with: OPEN 15,8,15,"S:P/program name":close It is often neessary to insert an existing routine into a Pasal program. The Pasal 64 ommand EXTERNAL is used to do this

10 Abaus Software PASCAL-64 The fornat is: EXTERNAL "routine nane"; No other statements may be on this line. In order to ompile a program whih ontains suh a line, you must first use the linker. Load the linker with LOAD"LINKER",8 and start it with RUN. Give it the name of the program and the name of the program to be reated. The linker reates a program whih, instead of the EXTERNAL, ontains the atual routine so referened. This routine must be on the same diskette. The line numbers of the routine will be renumbered and the line numbers of the main program will remain the same if there is enough room for the routine. The line numbers are irrelevant to Pasal. If the routine aessed via EXTERNAL ontains an EXTERNAL referene itself, this will NOT be exeuted and the linker will notify you. Suh a routine must first be run through linker before the main program in order to proess the nested EXTERNAL Linker and loader are independent of the Pasal 64 distribution diskette. The ompiler an be loaded from the distribution disk only, but linker and loader may be transferred to your work diskette In order to get used to the way the ompiler works, it would be a good idea to first read the following hapter and then link and ompile the following program. The external routine neessary for this program is found in Chapter 12. Main program: 10 CONST PI= ; 20 VAR X,Y,FX,FY,A,B,L,I,XL,YL,ST:REAL; 30 EXTERNAL "DRAW"; 40 BEGIN A:= -6; B:= 1; ST:= 5; FX:= 12; FY:= 12; 50 ST:= PI/ST; 60 GRAPHIC 1; SCREENCLEAR; 70 L:= -3; WHILE L< = 3 DO BEGIN 80 I: = 0; WHILE K = 2*PI DO BEGIN 90 X:= XL; Y: = YL; 100 XL:= (A+B)*COS(I)-L*B*COS((A+B)/B*I); 110 YL:= (A+B)*SIN(I)-L*B*SIN((A+B)/B*I); 120 IF IO0 THEN DRAW (X*FX+160,Y*FY+100,XL*FX+160,YL*FY+100); 130 I:= I+ST; END; 140 I: = 1+0.5; END; 150 REPEAT UNTIL PEEK(197)<>64; END; - 3 -

11 Abaus Software PASCAL-64 Chapter Organization of a Pasal program A Pasal program onsists of four parts: -1- Program header The program header ontains the name of the program. For subroutines, the subroutine parameters are also loated here. In Pasal 64, the main program header may be omitted. -2- Variable delarations Here all variables, onstants, types, et. are defined. -3- Subroutine delarations In this setion, all of the proedures and funtions alled from the main program or from other subroutines are defined. The subroutine definition has the same struture as the main program definition, that is, eah subroutine has its own variables and subroutines. -4- Program blok The program itself is loated in this part. The program may make use of all of the previously delared global variables (as opposed to variables defined within a subroutine, alled loal variables) and subroutines. The program must start with BEGIN and end with END The program blok of the main program is alled at the start of the program. This blok then alls the subroutines. After the END., ontrol is returned to the BASIC interpreter. 2.2 Domain of variables Beause a subroutine is organized the same way the main program is, it an have its own variables and its own sub routines. The variables of a subroutine annot be used by the main program or a higher-level (outer-nested) subrou tine. The subroutine however an make use of the variables of the main program or higher-level subroutine. In general, we an say that a variable delared at the top of a main program or subroutine beomes undefined or invalid following the END; of that blok

12 Abaus Software PASCAL-64 If a variable in a subroutine has the same name as that of another variable in a higher-level subroutine, the higher-level global variable loses its aessability to that variable for the duration of the subroutine in whih the onflit ours and will regain it again one the loal variable loses its definition. The value of the global variable is not affeted. Therefore you need not worry about hoosing unique names for eah of the variables in all of your subroutines. Thus this shortoming of BASIC is addressed by the Pasal language. 2.3 Defining a blok The program-blok portion of a main program or subroutine is delimited by the statemenmts BEGIN and END; (END. for a main program). A blok onsists of several statements and/or strutures (loops, et.), eah separated from the other by a semiolon. Within the strutures are one or more bloks. A blok onsisting of only one statement does not need a BEGIN and END;, as long as this onstrution makes sense (it does not for program bloks, for instane). 2.4 General syntax In Pasal, eah reserved word (keyword) must be followed by a spae. If a keyword requires parameters, they follow this spae. A semiolon signals the end of a statement and serves to separate one statement from the next. If a statement does not require a parameter list, the semiolon may be plaed immediately following the keyword. No spaes may appear within a list element of parameters, variables, or formulas. List elements are separated from eah other by ommas, not by spaes. Spaes may not be plaed before a semiolon or the semiolon is treated as a null statement and not as a statement separater. The end of a line (arriage return) is treated as a spae for the purposes of syntax. Naturally, where one spae is allowed, more may be used if desired, in order to show the struture of the program graphially. Example: READLN (VARIABLE1,VARIABLE2); WRITELN (VARIABLE1,VARIABLE2); WRITELN; The most ommon error made by beginners is the improper use of spaes, but the rules an be learned quite quikly beause they follow a logial pattern. Pasal 64 is more strit in its syntax than is standard Pasal but is more

13 Abaus Software PASCAL-64 tolerant in the use of Pasal apabilities. 2.5 Comments To plae a omment in a Pasal program, set it off from the rest of the program text as follows: (* omment *) The ompiler will ignore any and all text between the "(*" and the ")*". The information presented in this hapter will be explained in greater detail in the following hapters

14 Abaus Software PASCAL-64 Chapter Variable types In Pasal, four basi data types are available: -1- Whole numbers are denoted by INTEGER and may be values ranging from to A deimal point and any digits after will be ignored. INTEGER variables use only a small amount of memory (2 bytes) and an be manipulated quikly. Variables should be of type INTEGER whenever possible to save time and memory. -2- Real numbers are denoted by REAL and have the same value range and number of signifiant digits as BASIC floating-point variables. A floating-point number may be in the range +/ E+38. The number of signifiant digits is limited to 9. Eah floating-point number oupies five bytes in memory. In ontrast to BASIC, the first harater of a real number may not be a deimal point. If the absolute value of the number is less than one, a zero must preede the deimal point: must be written as The onversion from INTEGER to REAL and bak again is done automatially, if it is required in a alulation and is possible. When onverting from REAL to INTEGER, the plaes after the deimal are simply ignored, as is the ase with the DIV and NOD operators and the assignment of a floating-point result to an INTEGER variable. -3- Alphanumeri haraters are denoted by CHAR and CHAR variables may ontain any of the 64's printable haraters, inluding olor and ursor ontrol haraters. Alphanumeri haraters are enlosed in quotation marks. The CHAR type may not ontain strings; the data struture string is used for this purpose and is explained in hapter Variables of type BOOLEAN may ontain either of two values: TRUE or FALSE. All omparison operations yield a BOOLEAN value. A BOOLEAN value is a statement of the truth of the result of a mathematial operation. Suh a result is generally tested by an IF statement. The values TRUE and FALSE may also be assigned to a variable and later tested. This is useful for flags, for instane. The two values TRUE and FALSE are reserved words in Pasal

15 Abaus Software PASCAL Mathematial operations The following oatheoatial operations are possible in Pasal 64: +> -» *. / These operations work the same way as in BASIC and may be used with either REAL or INTEGER values and variables. ** This operator orresponds to the BASIC operator * and is used for exponentiation. The harater " is reserved for use with pointers in Pasal (hapter 9). Standard Pasal does not have an exponentiation operator. DIV This operator perforns a division but yields an INTEGER value and is therefore exeuted faster. NOD This operation is the ounter part of DIV. It yields the mathematial remainder of an integer division. AND, OR These operators are the same as their BASIC ounterparts, yielding an INTEGER value, and an be used for logial or binary operations, that is, they an be used with two BOOLEAN values to yield a BOOLEAN value. They an also be used with two integers and help with POKE and PEEK operations for setting or testing individual bits, as in BASIC. The omparison operators >, <, =, > =, <=, and <> also operate as in BASIC and may be used for all three data types. The result of these operations is either -1 = TRUE or 0 = FALSE (a boolean value). Two suh results nay be ombined with AND or OR and yield a result of true or untrue. Loops (REPEAT, WHILE) and IF make use of this onditional. Suh a result an also be assigned to a boolean variable and tested later. The funtion NOT(X) inverts a boolean value, hanging TRUE to FALSE or FALSE to TRUE. In addition, Pasal has the following pre-definied funtions: SIN(X), COS(X), TAN(X), EXP(X), ABS(X), PEEK(X), NOT(X) orrespond to the BASIC funtions with the same names. The argument may be of type REAL or INTEGER

16 Abaus Software PASCAL-64 TRUNC(X) yields the integer portion of a floating point number and orresponds to the BASIC funtion INT. SQR(X) returns the square of a number. SQRT(X) returns the square root of a number and orresponds to the BASIC funtion SQR. LN(X) returns the logarithm base e of a number. ARCTAN(X) returns the inverse tangent of a number and orresponds to the BASIC ATN. ORD(X) onverts a harater to the orresponding number ode. Corresponds to the ASC funtion in BASIC. CHR(X) onverts a number into a harater is the opposite of ORD. It performs the same operation as BASIC'S CHR$. SUCC(X) yields the suessor of a variable whih is the value plus one for INTEGER variables. PRED(X) Predeessor of a value. SUCC and PRED are generally used for user-defined data types. ROUND(X) rounds off a real number to the nearest whole number, is equivalent to TRUNC(X+0.5). RND(X) returns a random number between 0 and 1. Funtion operands must be enlosed in parentheses; this applies even to the NOT funtion. If your favorite funtion is missing, it an be implemented through a funtion or formula library: COT(X) : 1/TAN(X) ARCSIN(X) : ARCTAN(X/SQRT(1-X*X)) COSH(X) : (EXP(X)+EXP(-X))/2 LOG10 : LN(X)/LN(10) In Pasal, it is possible to define your own funtions. Chapter 5 explains how to do this. All four data types an appear as a variable, variable freld, onstant, or diret number in mathematial expression. All variables used in a program or subroutine must be delared before the start of the program, (see hapter 2)

17 Abaus Software PASCAL Program header The program header is the first part of a program and may be omitted in Pasal 64. Most of the programs in this manual do not have headers. Format: PROGRAM program name; 3.4 Variable delaration The keyword VAR tells the ompiler that you wish to delare variables. The variable names are separated from eah other by ommas; their type is indiated after a olon, and a semiolon followed by a spae separates this from the next variables. Example: VAR A,B,TEST:REAL; X,COUNTER:INTEGER; A:REAL; M,N:CHAR; A delared variable has no default value, not even zero. You must assign a value to eah variable in your program before its ontents are aessed, otherwise you will reeive a random value. The length of the variable names and the number of variables is limited only by memory. To define an array of a ertain type, the variable type is simply replaed with ARRAY[number..number] OF variabletype; VAR A,B,TBST:ARRAY[ ] OF REAL; This line defines the arrays A, B, and TEST with ele ment number running from -5 to This orresponds to the DIM ommand in BASIC. The indies of the array must be plaed within square brakets. Note that arrays of arrays are allowed and an be used to define multi-dimensional arrays (up to four dimensions). Note also that the indies need not start at zero but an start and end with any integer. This is desribed in hapter 6 in greater detail

18 Abaus Software PASCAL Constant delaration The keyword CONST is plaed before a list of onstants that are to be used in a program. A onstant is a name that is assigned a fixed value for the duration of the program. The value" of a onstant annot be hanged during program exeution. Examples are: CONST PI= ; YES=-1; NO=0; PAREN=M(M; The data type is automatially determined by the ompiler. A onstant may not be assigned a new value within the program. 3.6 Delaration of user-defined types In additional to the pre-defined data types, Pasal allows you to define your own, using the TYPE ommand: Example: TYPE COLORS(BLUE,RED,GREEN,YELLOW,WHITE,BLACK) Now variable of this type an be delared: VAR CARPETCOLOR:COLOR; and values assigned to them: CARPETCOLOR:= GREEN; The funtions SUCC and PRED an also be used with these data types. SUCC(GREEN)=YELLOW is a TRUE statement. These newly-defined data an appear anywhere within a formula other numbers or onstants may appear. 3.7 Arithmeti expressions Writing an expression in Pasal is done the same way as in BASIC. A set of operations, using algebrai hierarhy, all variables and data types and unlimited use of parentheses permitted in Pasal. The following exeptions must be noted: -A spae must be plaed before and after the operators AND, OR, MOD, DIV, and IN so that the ompiler does not think these operators are part of a variable name. Variable

19 Abaus Software PASCAL-64 nanes are permitted to ontain these operators meaning COLOR is a legal name although it ontains the OR operator. Beause the spae in front of these operators may be replaed by a arriage return, an expression may span several lines. The spae after these operators may not be replaed by a arriage return, however. -No other spaes may appear within an expression. -The index of an array is plaed within square brakets and may be an expression. Indies may also be negative values if suh has been delared. -User-defined funtions may be used as pre-defined funt ions; funtion arguments may be onstants, variables, or expressions. -The negation of a variable using the unary minus is not allowed: operator B:= -B; must be replaed by B:= B*-l; The alulation hierarhy in Pasal is slightly different than that in BASIC: -The parentheses have the highest priority. This also app lies for funtion parameters, whih must be enlosed in parentheses. -Then the operators *, uted. /, **, DIV, MOD, and AND are exe- -Next, the operators +, -, and OR have preedene. -Last, the omparison operators (<, >, =, <>, <=, >=) and the set operator IN are exeuted. Chapter 8 ontains more information about sets. The logial operators AND and OR do not have the equal priority in this hierarhy. This is aording to the Pasal standard, however, and is therefore implemented in Pasal 64. It is reommended that parentheses be used in express ions involving these operators to avoid errors. 3.8 The Pasal assignment statement In order to assign a value to a variable, following assignment instrution: one uses the variable:= expression;

20 Abaus Software PASCAL-64 or for arrays: variable[expressionl]:= expression2; The variables on the left side are assigned the result the of the expression on the right side. This assignment is similar to the assignment in BASIC. The primary differene is that in Pasal, a olon is required before the equal sign in order to distiguish it from the equality omparison operator. In addition, a spae oust follow the equal sign beause the assignment operator is a Pasal ommand and a reserved word (see hapter 2). Example: FIELD[3+4]:= SIN(B); The sine of 8 is assigned to the seventh element of the array, assuming the array is of type REAL. 3.9 Input and Output In order to read a number or harater from the keyboard, one uses the READ ommand: READ (variablel,variable2,...,variablen); This ommand reads values into the variables separated by ommas. When reading numbers, the values must be separated from eah other by a spae or RETURN. If the variable is of type CHAR, only one harater is read. The READLN statement may be used instead of the READ statement. The READLN statement waits for a RETURN at the end of the input: READLN (X,Y); If the following input is entered: <RETURN> then the first two numbers are assigned to the variables X and Y, respetively, the number 4 is ignored, and the ursor moves to the next line. The READ statement saves the number 4 for the next input. To output results, Pasal has the WRITE statement: WRITE (variable,expression,"text",...); It is possible to output the result of any desired expression with the WRITE statement. In addition, text

21 Abaus Software PASCAL-64 plaed within double quote marks are also be printed. Text may be omprised of any haraters whih an be represented within the double quote narks (suh as ursor ontrol haraters). If an array of type CHAR is output without speifying the index, the entire array is printed as a string (hapter 6). With values of type BOOLEAN or of a user-defined type, the orresponding number is printed. The WRITELN statement is just like the WRITE statement, exept that it plaes a RETURN at the end of the output. To print just a RETURN, use the WRITELN statement without parameters: - WRITELN; Corresponding BASIC ommands are: READLN WRITELN WRITE INPUT PRINT PRINT When entering multiple numbers, they must be separated by spaes, not by ommas as in BASIC. Unfortunately, the kernal of the Commodore 64 ontains a small error. If an input takes plae on the same line as additional input or some output suh that the input exeeds the end of the line, the entire line is read as input. The following BASIC program illustrates this: 10 INPUT"Text longer than 40 haraters1*; A$: PRINTA$ Not only is the data assigned into the string variable A$, but the prompt text also beome part of A$ as well. Beasue this error is not in the BASIC interpreter but in the kernal, it also ours in Pasal 64. The READ statement an be used with a variable of type CHAR to read individual haraters. The ursor appears on the sreen and haraters are read until RETURN is pressed. To avoid this, the GET statement an be used instead: Format: GET variable; This statement orresponds to the BASIC GET ommand. It fethes a harater from the keyboard buffer and returns it in the given variable. If the keyboard buffer is empty, a CHR(O) is returned

22 Abaus Software PASCAL Formatted numeri output In Pasal it is possible to output numbers in a uniform format. This is permitted on the sreen or printer (hapter 7) using the WRITE or WRITELN statements. Format: WRITELN (expression:valuel:value2); The two values may be numbers or variables. The first value gives the total length of the output. If the output is shorter than this length, the output is right-justified within a field of valuel spaes. The seond value gives the number of plaes after the deimal. Numbers with an exponen tial portion (numbers that must be represented in sientifi notation) annot be formatted in this manner. To line up deimal points on a olumn of numbers, hose the same values for all of the output. The deimal point is plaed at valuel-value2. For this reason, the first value must always be greater than the seond. With the ommands we have disussed so far, it is possible to write a small Pasal program: 5 PROGRAM FIRST; 10 VAR INPUT,RESULT:REAL; 20 (* NO SUBROUTINES NECESSARY *) 30 BEGIN (* START OF THE MAIN PROGRAM *) 40 WRITELN ("I AM WAITING FOR A NUMBER."); 50 READLN (INPUT); 60 RESULT:= SIN(INPUT); 70 WRITELN (HTHE SINE OF THE INPUT IS:M,RBSULT:10:4); 80 END. (* END OF THE MAIN PROGRAM *) This program an be ompiled and exeuted as desribed in hapter

23 Abaus Software PASCAL-64 Chapter Control strutures Loops and onditional branhes are used to ontrol the order in whih program statements are exeuted. You are already familar with one type of loop from BASIC: the FOR... NEXT loop. You are also aquainted with IF... THEN statement for onditional branhing. This branh is limited to a single line in BASIC. In Pasal, the end of the line is treated as a spae, making it possible for the THEN portion of an IF... THEN statement to span multiple lines. The BEGIN and END; markers are used to set off the blok whih are exeuted if the ondition is true (the THEN portion). In Pasal, a blok demarated by BEGIN and END; may appear anywhere a single statement is allowed. BASIC also has the apability to fore and unonditional branh with the GOTO ommand. Beause of Pasal's effiient strutured ommands, this unstrutured statement is unneessary and ontradits the onept of Pasal. For the sake of ompleteness, it is inluded anyway, although it should be used only very rarely... 2 Loops The REPEAT statement Format: REPEAT blok UNTIL ondition; REPEAT and UNTIL replae the blok markers BEGIN and END. Operation: The statements of "blok" are be exeuted, the ondition (omparison or any other expression whih returns a boolean value) is heked, and the statements of "blok" are re-exeuted provided that the ondition has not been satisfied (is FALSE). The blok is exeuted until the ondition is satisfied (TRUE) at whih time exeution resumes with the statements following the UNTIL. Example: 10 VAR COUNTER:INTEGER; 20 BEGIN COUNTER:= 1; 30 REPEAT 40 WRITELN (COUNTER); 50 COUNTER:= COUNTER+1; 60 UNTIL COUNTER)10; 70 END

24 Abaus Software PASCAL-64 This program prints the numbers 1 through 10. The number 11 is not printed sine the ondition is heked firset and found to be satisfied. Note that the variable COUNTER is first defined before it is used The WHILE statement Format: WHILE ondition DO blok; The ondition is heked and the blok is exeuted only if the ondition is TRUE. At the end of the blok, the ondition is again heked and the blok re-exeuted depending on its truth value. If the ondition is false, exeution ontinues with the statement following the blok. In ontrast to the REPEAT/UNTIL struture, the blok is not exeuted at all if the ondition is false to begin with, whereas the blok is always exeuted at least one with REPEAT/UNTIL. Example: 10 VAR COUNTER:INTEGER; 20 BEGIN COUNTER:= 1; 30 WHILE COUNTER<11 DO BEGIN 40 WRITELN (COUNTER); 50 COUNTER:= COUNTER+1; 60 END; (* END OF THE LOOP *) 70 END. This program also prints the numebr 1 through 10. If the ounter equals 11, the ondition is no longer satisfied and the blok is skipped The FOR statement Format: FOR variable:= start value TO end value DO blok; The variable is initially assigned the start value, the blok is exeuted, and the variable is inremented by one. The blok is again exeuted and the variable inremented until the variable is greater than the end value immediately following its inrementation. If the start value is larger than the end value at the start of the loop, the blok is not exeuted. Program exeution ontinues one the end value is exeeded. The start and end values may be expressions and the variable must be of type INTEGER. The end value is realulated eah time through the loop, allowing it to be

25 Abaus Software PASCAL-64 hanged within the loop. The loop an also be made to ount down: FOR variable:= start value DOWNTO end value DO blok; The variable is deremented and the blok is skipped when its value is smaller than the end value. Example: 10 VAR COUNTER:INTEGER; BEGIN 20 FOR COUNTER:= 1 TO 10 DO 30 BEGIN WRITELN (COUNTER); END; 40 END. Again we have a program whih prints the number 1 through 10. By using a FOR loop, the initial assignment of the ounter, the inrementation of the variable, and the heking of the ondition are all done automatially. The WHILE ommand must be used to inrement the variable by a number other than +1 or -1. If the blok onsists of only one statement, the BEGIN and END may be omitted. As we mentioned before, strutures may be nested within a blok. The nesting depth is arbitrary, but may need to be inreased at ompile time (see hapter 1). As you an see, Pasal offers several different ways of formulating a program. The best method depends on the prob lem at hand. You should beome familiar with all of the types of loops. REPEAT and WHILE an be used for more than just ounting loops. The following program waits for a keypress: 10 BEGIN 20 REPEAT 30 UNTIL PEEK(203)<>64; 40 END. Memory loation 203 ontains the ode for the urrently pressed key. If no key is being pressed, the loation on tains 64. The memory addresses 0 through 1023 are the same in Pasal as they are in BASIC. Other system addresses are also retained (suh as the sprite registers or the address of the sreen memory)

26 Abaus Software PASCAL Conditional statements The IF statement Format: IF ondition THEN blokl; ELSE blok2; or IF ondition THEN blokl; If the ondition is fulfilled (TRUE), blokl wwill be exeuted, otherwise blok2 will be exeuted, if it exists. Example: 10 VAR INPUT:REAL; 20 BEGIN 30 READLN (INPUT); 40 IF INPUT<5 THEN BEGIN WRITELN (MTHE INPUT IS SMALLER THAN 5W); END; 50 ELSE BEGIN WRITELN ("THE INPUT IS GREATER THAN OR EQUAL TO 5M); END: 60 END. Sine the bloks in this example are only one statement long, the BEGIN and END may be omitted. This program makes only a rough statement about the variable INPUT. The following instrution allows a more exat statement about a variable or expression: The CASE statement Format: CASE expression OF number,number,number,...,number: number,...,number: blok2; number,...,number: blokn; END; blokl; The numbers must be of type INTEGER, although haraters of type CHAR may also be used instead if the expression yields suh a result. Floating-point numbers are not allowed. Operation: The expression is evaluated and the blok assoiated with the number or harater equal to the result of the expression is exeuted. The END; denotes the end of the CASE list and belongs to the CASE statement, not to a blok. If no math is found for the result of the expression,

27 Abaus Software PASCAL-64 exeution ontinues with the statement immediately following the END; of the CASE statement. Example: 10 VAR INPUT:INTEGER; 20 BEGIN 30 READLN (INPUT); 40 CASE INPUT OF 50 ; 1,2,3: BEGIN WRITELN ("1 TO 3"); END; 60 ; 4,5,6: BEGIN WRITELN ("4 TO 6"); END; 70 ; 7,8,9,10,11: BEGIN WRITELN (M7 TO 11"); END; 80 END; (* OF CASE *) 90 END. (* OF PROGRAM *) The semiolon at the start of eah line serves only to separate the line numbers from the numbers in the CASE statement. This program gives a more exat desription of the ontents of the variable INPUT than the previous program. 4.4 The GOTO statement Format: GOTO label; label: statement; As soon as the program enounters a GOTO statement, the exeution of the program is interrupted and resumes at the label. The jump need not be forward. The label an be a number or a name. It is reommended that the label ontain information on the line numbers between whih the jump ours so that the program flow may followed easily. Eah label may be jumped to from only one GOTO. Example: 10 VAR COUNTER:INTEGER; 20 BEGIN COUNTER:= 1; 30 FRON60TO30: 40 WRITELN (COUNTER); 50 COUNTER:= COUNTER+1; 60 IF COUNTER<11 THEN GOTO FROM60TO30; 70 END. This program also outputs the numbers from 1 to 10, but this anot be seen diretly from the program text, only by following the jump. You should use the GOTO only in speial

28 Abaus Software PASCAL-64 ases sine it an be avoided in virtually all instanes, although this may not be obvious to a BASIC programmer. The elimination of GOTO will make your programs easier to under stand and modify. In Pasal, the destination of a jump is limited. A jump into a blok is not allowed. A jump within the same blok is permitted, as is a jump to the outside of a blok. JUmping out of a subroutine or CASE struture is strily forbidden. To exit a subroutine, it suffies to jump to the end of the routine. There are similar restritions in BASIC. Exiting a subroutine with GOTO an result in a stak overflow and a jump into a loop results in a NEXT WITHOUT FOR. 4.5 Using ontrol strutures In order to illustrate a pratial use of ontrol strutures, we present the following program whih prints the prime numbers under The program uses the prin iple in whih all of the multiples of prime numbers are removed from a table beause they are no longer prime num bers. The first number will take a fairly long time to alulate. The important part is to note the nesting of the bloks. All END statements are followed by a omment whih indiates to whih struture they belong. All BEGIN and END statements whih are optional are shown as omments. 10 CONST N=10000; 20 VAR Z:PACKED ARRAY[ ] OF BOOLEAN; 30 K,I:INTEGER; 40 BEGIN 50 FOR I: = 1 TO N DO 60 ; (* BEGIN *) 70 ; Z[I]:= TRUE; 80 ; (* END OF FOR *) 90 WRITELN (2); 100 FOR I := 1 TO N DO 110 ; (* BEGIN *) 120 ; if Z[I] THEN 130 BEGIN 140 WRITELN (2*1+1) 150 K:= 1; 160 WHILE I+K*(2*I+1)<=N DO 170 BEGIN 180 Z[I+K*(2*I+1)]:= FALSE; 190 K:= K+l; 200 END; (* OF WHILE *) 210 END; (* OF THEN *) 220 ; (* END OF FOR *) 230 BND. (* OF THE PROGRAM *) Type this program in and ompile it as desribed in Chapter 1. It runs signifiantly faster than a orresponding

29 Abaus Software PASCAL-64 BASIC program even though it exeutes a omplex index al ulation in order to save spae. Bnter the following line: 45 INTEGER; and reompile the program. The program should run even faster than before. We will say more about this ommand in hapter 10 so do not use in other programs until then

30 Abaus Software PASCAL-64 Chapter Proedures and funtions The proedure defintions in Pasal are plaed before the oain program and after the variable delarations. They onsist of a parameter portion, the proedure variable delarations, nested proedure delarations, and the proedure blok. This onstrution is similar to that of the main program Proedure delaration Format: PROCEDURE name (parameter list); variable delarations nested proedure delarations blok; More proedure delarations may follow the END; statement of the blok. The parameter list, the variable delarations and any nested proedure delarations are all optional. If proedure has no parameters, the semiolon is plaed immediately following the name. Variable delarations were previously explained in Chapter 2. The delaration of a proedure nested within a proedure follows the same pattern as the delaration of a proedure of the main program. An outer proedure's variables belong to both the outer proedure and the nested proedure. Variables of the main program an be used by all proedures as well as the main program. For this reason they are alled global variables. Eah program blok should use only its own variables in order to avoid onfusion. Passing data between proedures and the main program should be aomplished via parameters, variables whih the main program or alling routine defines are delared in the parameter list. There are two types of parameters: Value parameters: These parameters are delared as variables, but without the word VAR. When the proedure is alled, the value parameters are given a value by the alling program. Variable parameters: The word VAR in front of a delaration is used to distiguish variable parameters from value parameters. A variable parameter is passed by the PROCEDURE all, and an be manipulated under the name of the variable parameter. It is thereby possible for the proedure to use variables of the alling program without the need for these variables to have a speifi name. Eah all

31 Abaus Software PASCAL-64 of the proedure an pass a different variable. If the value of a variable paraneter is hanged by a proedure, the value of the variable in the alling program is also hanged. Variable parameters offer the apability of passing results to the alling routine. The paraneters of a proedure an also be ARRAYS or RECORDS. These data types oust be delared as variable parameters. More about arrays and data reords in found in the next hapter. Example: PROCEDURE TEST (VAR A,B:INTEGER; CrREAL; VAR X,Y:CHAR); The variables A, B, X, and Y are variable paraneters while the variable C is a value parameter. All parameters an be used by the proedure as variables. The differene between parameters and variables delared within the proedure is that parameters have a value defined by the alling routine, whereas the proedure variable are initially undefined Calling proedures Format: name (parameterl,parameter2,...,parametern); The values of the parameters are passed to the named proedure and this is then exeuted. Variable parameters may only be variables, not expressions, due to their nature. Example: TEST (I,K,COS(3*5+Q),S,N); A proedure may also all other proedures. If the alled proedure does not belong to the alling proedure, it must be previously delared. A proedure name may not have the same name as a Pasal reserved word. Here is an example of a proedure named INPUT whih has as a parameter a real variable: 10 VAR X:REAL; 20 PROCEDURE INPUT (VAR NUMBER:REAL); 30 (* NO PROCEDURE VARIABLES NEEDED *) 35 (* NO NESTED PROCEDURES NEEDED *) 40 BEGIN 50 WRITELN ("PLEASE ENTER A NUMBER"); 60 READLN (NUMBER);

32 Abaus Software PASCAL END; (* PROCEDURE *) 80 BEGIN (* OF THE PROGRAM *) 90 INPUT (X); 100 WRITELN ("YOU ENTERED ",X,"."); 110 END. The proedure works like a new statement. It would be possible, for instane, to expand the graphis statements of Pasal 64 using proedures (see hapter 12). In many ases, it also desirable to be able to define a new funtion. Pasal offers us this apability Funtion delaration Format: FUNCTION name (parameter list):funtion type; variable delarations subroutine delarations blok; Everything that was said about proedures also applies to funtions, exept that the parameter list must ontain at least one element. In addition, a funtion variable is def ined having the name of the funtion and the type given as funtion-type. The type may be any of the four basi data types or a one-dimensional array. The ability to use arrays is important for writing string funtions, for instane. The funtion variable must be assigned a value, whih represents the result of the funtion, within the funtion blok. Otherwise, the funtion variable an be treated as a normal variable. For arrays, the individual fields must be assigned. Calling a funtion is done the same way pre-defined funtions are alled. The parameter passing works in the same as for proedures. Here is an example of a funtion named FACTORIAL. It omputes the fatorial of a value-parameter that is passed to it (N) and returns this as a real number. The fatorial of a positive integer n is defined as n(n-l)(n-2)(n- 3)...(3)(2)(1). 10 VAR INPUT:INTEGER; 20 FUNCTION FACTORIAL (N:INTEGER):REAL; 30 VAR COUNTER:INTEGER; 40 BEGIN 50 FACTORIALS 1; 60 FOR COUNTER:= 1 TO N DO 70 FACTORIALS FACTORIAL*COUNTER; 80 END; (* OF THE FUNCTION *)

33 Abaus Software PASCAL BEGIN 100 READLN (INPUT); 110 WRITELN (FACTORIAL(INPUT)); 120 END. 5.2 Reursion In Pasal, it is possible for a proedure or funtion to all itself. This onept is alled reursion. A reursive routine oust of ourse have some means of determining when to stop alling itself based on when a ertain ondition is met. In ontrast to BASIC, the variables initialized in or passed to one proedure all are not destroyed by suessive alls. After returning from a all, the variables are returned to their original ondition. Eah new all generates new loal variables whih disappear again after eah return. The possibilities whih loal/global definitions permit are shown learly in reursion. Many programs whih would normally require a stak to manage data an be written using reursion instead. One example of reursion is the number of moves ahead whih a hess program alulates. The new generation of variables applies to all variables in the subroutine, even for arrays and omplex data strutures. This is an example of a reursive funtion to alulate fatorial. As you reall, the fatorial of n is defines as n(n-l)(n-2)...(3)(2)(l). Here we alulate n fatorial by first alling FACTORIAL with the parameter n, whih then alls itself with a new parameter, (n-1), until the parameter passed to the funtion is equal to VAR INPUT:INTEGER; 20 FUNCTION FACTORIAL (N:INTEGER):REAL; 30 BEGIN 40 IF N>1 THEN FACTORIALS FACTORIAL (N-1)*N 50 ELSE FACTORIAL:= 1; 60 END; 70 BEGIN 80 READLN (INPUT); 90 WRITELN (FACTORIAL(INPUT)); 100 END. Sine the parameter n is deremented with eah new all, it will eventually reah the limiting or ending value (1). The reursion ends and all of the n's from the various levels will be multiplied together. Reursion an also be set up by having a subroutine all a higher-ordered subroutine and having this subroutine all the lower-level routine. Reursion an also beome even more omplex, involving multiple subroutines

34 Abaus Software PASCAL Exiting a proedure Under ertain onditions, it may happen that the rest of a proedure need not be exeuted, suh as when an output subroutine determines that an output devie is not onneted. Naturally, this problem ould be solved with an IF-THEN-ELSE ondition. It is simpler however to use the ommand EXIT. Format: EXIT; This statement auses the urrent proedure to stop exeution and fores a return to the alling routine. When used in the main program, EXIT auses the program to end. Sine EXIT orresponds to a GOTO to the end of the proedure, it should be thought in muh the same manner as the GOTO, although it is somewhat learer

35 Abaus Software PASCAL-64 Chapter 6 In the previous hapter we presented all of the basi elements of Pasal so that you are now ready to develop your own Pasal programs. Chapter 13 will assist you with this. Now, however, we turn to the more advaned features of Pasal. 6.1 Data strutures In Pasal we have the ability to struture not only programs but data as well. A data struture onsists of several elements. The data type of these elements may be the same throughout the struture (ARRAY) or may be different from element to element. It is important to note that the elements of a struture do not have to be one of the four basi types, but an themselves be strutures. Beause a data struture onsists of several elements, exatly as a program blok onsists of several statements, it seems reasonable to refer to data strutures as data bloks. Pasal offers many possibilities for working with data bloks, so in the following hapters, we will refer to an arbitrary data struture as a data blok. For example, the statements for manipulating strings an also be used for other strutures despite the fat that they were not speifially written for these strutures. 6.2 ARRAYS An array an be omposed of elements of any desired type of data. You are already familiar with arrays from BASIC (DIN ommand, et). Eah array must be delared before it an be used as a variable: VAR name:array[number1..number2] OF data type; You have already seen this delaration in hapter 3. The two numbers in the delaration give the minimum and maximum index of the array. In ontrast to BASIC, the min imum index need not be zero. In fat, both number may be negative. Numberl must of ourse be smaller than number2. Theoretially, the numbers may be any desired integers, but the pratial limit is the amount of memory available for variable storage. Speial attention must be paid to this for arrays of type REAL sine real variables require 5 bytes eah. The data type an be any desired data type, even another array:

36 Abaus Software PASCAL-64 VAR ARR3D:ARRAY[1..10] OF ARRAY[2..5] OF ARRAY[-3..4] OF REAL; To save spae, this an also be written: VAR ARR3D:ARRAY[1..10,2..5,-3..4] OF REAL; An array an have up to four dimensions. An array element is aessed by plaing the index in square brakets behind the array name. The index may be an expression. The array element seleted in the manner may be used as normal variable: ARR3D[X,Y,Z] This is how an element of the array is aesed. The individual element is of type REAL an be manipulated as any REAL variable. A three-dimensional array is a two-dimension al array of one-dimensional arrays. One an aess an ele ment of this two-dimensional array and reeive as a result a single-dimensional array: ARR3D[X,Y] This gives us a data blok with ontains all of the array elements having the first dimension X and seond dimension Y. The data blok is a one-dimensional array. The following expression yields a two-dimensional array: ARR3D[X] and the entire three-dimensional array is aessed with: ARR3D All operators whih apply to data bloks may be used on suh arrays. One suh operator is the assignment operator: TEMPARRAY:= ARR3D; TEMPARRAY[1,2]:= ARR3D[4,5]; Naturally, only data bloks having the same size and index range (that is, the same type) may be assigned to eah other. Another possibiltiy is that data bloks may be trans mitted to subroutines as parameters. Data bloks an also be written to and read from files (hapter 7)

37 Abaus Software PASCAL RECORDS Pasal's abilities to work with data bloks do not end with arrays. For example, an address list ontains not only haraters but also numbers. This ombination of several different data types is diffiult to represent in a single array. Pasal offers the ability to ombine several data types into one ohesive unit (RECORD). The individual var iables are set off by RECORD and END; and represent a new data type. VAR name,name,...,name:record namel:data name2:data type; type; END; namex:data type; The data types of the variables may be any of the basi four, they may be arrays, and even other reords. The fol lowing delaration is possible: VAR ADDRESS:RECORD NAME:RECORD FIRSTNAME:ARRAY[1..10] OF CHAR; LASTNAME:ARRAY[1..10] OF CHAR; STREET:ARRAY[1..15] OF CHAR; CITY:ARRAY[1..15] OF CHAR; STATE:ARRAY[1..2] OF CHAR; ZIPCODE:INTEGER; END; An individual reord element is aessed by plaing a period followed by the name of the element behind the reord name. The following types of referenes an be made: ADDRESS.ZIPCODE ADDRESS.CITY ADDRESS.NAME.FIRSTNAME ADDRESS.NAME.LASTNAME[1] ADDRESS.NAME ADDRESS is of type INTEGER is an array of type CHAR is an array of type harater is the first harater of the last name is a two-element RECORD ontains all of the address data These parts of the reord an be manipulated as desired sine they either refer to other reords or are atually variables. Data bloks an again be assigned to eah other: ADDRESS.NAME.FIRSTNAME:= ADDRESS.NAME.LASTNAME;

38 Abaus Software PASCAL-64 Reords may also serve as subroutine parameters. All oper ations possible with data bloks of type ARRAY are also possible with reords. 6.4 Combining RECORDS and ARRATs Sine we an make an array of any data type, we an also make arrays of reords. Several reords of the same type an thereby be brought together in an array: VAR NAMELIST:ARRAY[1..100] OF RECORD FIRSTNAME:ARRAY[1..10] OF CHAR; LASTNAME:ARRAY[1..10] OF CHAR; END; Reords and arrays may be nested inside eah other as desired. The nesting of reords is abitrary, the nesting of arrays is limited to four dimensions. If the last data type of a reord is not a basi data type but always another reord, only three dimensions may be used. It should be noted that an individual element of suh a struture is aessed first by the reord element and then by array element: NAMELIST.FIRSTNAME[10] NAMELIST[11] NAMELIST NAMELIST.LASTNAME[20,2] the last name of the tenth person both names of the 11th person the entire file the seond letter of the last name of the 20th person A possible use of this file might be for sorting names alphabetially beause the following assignment is possible: NAMELIST[X]:= NAMELIST[Y]; Reords an be used for more than just addresses. They may be used for any group of data whih have something in ommon or just belong together. A typial use might be the three oordinates whih denote a point in a three-dimension al Cartesian oordinate system. Another mathematial use is for storing omplex numbers

39 Abaus Software PASCAL WITH statement In nany ases, several suessive referenes have to aade to the sane reord. Eah time the reord is aessed, the reord name must be given. This is made easier if we use the WITH statement. Format: WITH reord name DO BEGIN statements; END; Example: READLN (NAMELIST.FIRSTNAME[1],NAMBLIST.LASTNAMB[1]); NAMELIST.FIRSTNAME[2]:= NAMELIST.FIRSTNAME[1]; This an be shortened to: WITH NAMELIST DO BEGIN READLN (FIRSTNAME[1],LASTNAME[2]); FIRSTNAME[2]:= FIRSTNAME[1]; END; The ompiler plaes the reord name in front of all variables, providing doing so does not ause an error. If several WITH ommands are nested, the ompiler plaes both reord names in front of the variable names. A nested WITH onstrution must orrespond to a nested RECORD struture. Example program: 10 VAR DFILE:ARRAY[1..20] OF RECORD 20 FIRSTNAME:ARRAY[1..10] OF CHAR; 30 LASTNAME:ARRAY[1..10] OF CHAR; 40 END; 50 I:INTEGER; CHOICE:CHAR; 60 BEGIN 70 WITH DFILE DO BEGIN REPEAT 80 WRITE ("O=OUTPUT, I = INPUTrt); REALN (CHOICE); 85 WRITE (WRECORD?M); READLN (I); 90 CASE CHOICE OF 100 MOM: BEGIN WRITELN (FIRSTNAME[I],LASTNAME[I]); END; 110 "I": BEGIN READLN (FIRSTNAME[I],LASTNAME[I]); END; 120 END; 130 UNTIL CHOICB=M*"; END; END;

40 Abaus Software PASCAL Working with strings Subranges In standard Pasal, a string is represented as an array of haraters. Sine suh an array represents a data blok, we already have operators for strings. In many ases, how ever, we want to work with just part of the string, not the whole thing. For this reason, Pasal 64 gives you the abil ity to form subranges. To speify a subrange, you use the starting and ending values, separated by two periods, in stead of the array indies: array[start value..end value] The starting and ending values nay be expressions. Sine the subrange defined in this Banner is itself a data blok, all of the data blok operations may be perforned on it. A setion an be formed from any array in any dimension. The individual elements need not be one of the four basi data types, although they are most often of type CHAR. In all ases, the setion must be the last dimension given. No additional dimension indies may follow, even if the array has additional dimensions. Array subranges may also be form ed from ARRAY/RECORD ombinations. The following examples demonstrate the possibilities whih are possible for string manipulation: The following arrays are defined: VAR STRING1,STRING2:ARRAY[ ] OF CHAR; To insert a harater into a string, one uses the following statements: STRING1[ ]:= STRING1[54]:= "A"; STRING1[ ]; The string struture from 54 on is moved up by one memory loation and the harater "AM is plaed in the vaated loation at 54. An entire string array may be inserted in the same manner. To delete the harater again, one would write: STRING1[ ]:= STRING1[ ]; The order in whih the arrays subrange are speified in the assignment determines in whih diretion^the shift will take plae. In the first example, the upper subrange was speified first, meaning that the shift diretion is up. In the seond example, the shift diretion is down sine the lower subrange is speified first. Many versions of Pasal have similar expansions of standard Pasal for string man agement, but the shift diretion must usually be speified

41 Abaus Software PASCAL-64 expliitly (MOVELEFT, MOVERIGHT). In Pasal 64, the ompiler determines this automatially. Data blok assignments offer even more apabilities: STRING2[1..50]:= STRING1[50..99]; The first 50 elements of the array STRING2 are assigned the given subrange of STRING1. The ending value, and with it the length of the subrange, is given twie in the assign ment. This is not absolutely neessary. The ompiler is only interested in the length of the subrange to be manipulated: STRING2[1..0]:= STRING1[50..99]; Sine the array STRING2 starts with the index 1, we an shorten the assignment still more: STRING2:= STRING1[50..99]; With the statements and tehniques we have learned so far, it would not be diffiult to write a simple word pro essor. We have already shown examples of the two basi funtions of a word proessor, insertion and deletion. Al though moving entire array setions is done faster than moving haraters element by element with a loop, the speed of the 64 is not limitless. With very large strings (20000 bytes), inserting a harater may take several seonds. It is a good idea not to insert haraters one at time for this reason. Subranges of arrays are permitted whereever any other type of data blok is allowed. One exeption is the variable parameter of a subroutine, sine only entire data strutures may be passed to subroutines The length of strings Sine not all of the haraters of a string may be used immediately, it is a good idea to have a marker for the end of the string. Pasal 64 uses CHR(0) and fills all unused elements of a string with this harater when inputting from the keyboard. When printing to the sreen or printer, only the haraters preeding the CHR(0) are displayed and any thing after the CHR(0) is ignored. The funtion LENGTH an be used to determine the length of a string: Format: LENGTH(data blok) This funtion returns the number of elements in the array

42 Abaus Software PASCAL-64 preeeding a CHR(O). Although it may be used with other data bloks, it has meaning only for strings. Example: STRING[1..LENGTH(STRING)] returns all of the elements of the array up to the first CHR(O). STRING[1..LENGTH(STRING)+1] returns all of the array elements up to and inluding the first CHR(O) enountered. In this ase, the CHR(O) MUST be present Beause eah newly assigned string has an end and does not neessarily oupy the entire array, programs must al ways hek for and inlude a CHR(O) at the end of a string. Exept for input, a CHR(O) is not automatially plaed at the end of a string Additonal string operations The following statement is used to fill an array with a harater: FILLCHAR (data blok,harater); If the harater hosen is CHR(O), all elements of the blok are leared and onsidered to be defined. The STR statement serves to onvert a number into a string: STR (expression,data blok); The result of the expression is onverted into a harater string. The data blok must be large enough to ontain all of the digits. The inverse of STR is a funtion alled VAL: VAL (data blok) The data blok (string) is onverted to a number. This orresponds to the BASIC ommand VAL. There is a simple method for forming an array of type CHAR: "Text for the array* The text enlosed in quotation marks is a data blok beause it is longer than a single array element. Note that standard

43 Abaus Software PASCAL-64 Pasal requires that strings be enlosed in single quotes. Pasal 64 uses quotation marks (also alled double quotes) so that ursor and olor ontrol haraters nay be inserted into the string when using the BASIC editor. The data blok is automatially terminated with a CHR(O). You an initialize an array as follows: STRING:= MSOME TBXT FOR THE ARRAY"; The text may ontain ontrol haraters. The omparison operators <, >, =, <>, <=, >= are defined for strings. The result of a omparison is determined based on alphabeti ordering, as it is in BASIC. A CHR(O) again ats as an end-of-string marker. The expression STRINGKSTRING2 is TRUE if the ontents of STRING1 ome alphabetially before the ontents of STRING2; otherwise it is FALSE. The following program sorts strings: 10 PROGRAM SORT; 20 VAR ARR:ARRAY[1..2O] OF ARRAY[1..1O] OF CHAR; 30 VAR STRING:ARRAY[1..10] OF CHAR; I,J:INTEGER; 40 BEGIN 50 FOR I:= 1 TO 20 DO READLN (ARR[I]); 60 FOR J:= 1 TO 19 DO 70 FOR I:= 1 TO 19 DO 80 IF ARR[I]>ARR[I+1] THEN 90 BEGIN STRING:= ARR[I]; 100 ; ARR[I]:= ARR[I+1]; 110 ; ARR[I+1]:= STRING; 120 END; 130 FOR I:= 1 TO 20 DO WRITELN (ARR[I]); 140 END. 6.7 String funtions You may find that some string funtions found in BASIC are missing from Pasal 64. But sine the result of a Pasal funtion may be an array, it is easy to write your own string funtions: 10 VAR A,A1:ARRAY[1..100] OF CHAR; 20 FUNCTION MID (A:ARRAYf1..100] OF CHAR; I,J:INTEGER):ARRAY[1..100] OF CHAR; 30 BEGIN 40 MID:= A[I..I+J-1]; 50 MID[J+1]:= CHR(O); 60 END;

44 Abaus Software PASCAL FUNCTION CONCAT (A,B:ARRAY[1..100] OF CHAR): ARRAY[1..1OO] OF CHAR; 80 BEGIN 90 CONCAT:= A; CONCAT[LENGTH(A)+1..0]:= 100 END; 110 BEGIN 120 READLN (A,A1); 130 WRITELN (CONCAT(A,Al)); 140 WRITELN (MID(A,10,5)); 150 END. B[1..LENGTH(B)+1]; Note that the variable A is delared more than one and eah time represents a different variable with a different storage plae, orresponding to the Pasal loal/global definitions. This means that in the main program you do not have to worry about whih variables the subroutines use. The funtion MID requires the same parameters as the orresponding BASIC funtion. The funtion CONCAT aepts two strings as input, plaes one after the other, and returns this single string. Both funtions expet strings ending with CHR(O) and return suh an array. Additional funtions an easily be added in the same manner. 6.8 Paked arrays Larger omputers ontain memory with more bits per word than does the Commodore 64. It would be wasteful of memory to assign an entire memory loation to a variable whih might require just one bit (boolean). For this reason, Pasal has the ability to pak multiple array elements into a single memory loation (PACKED ARRAY). On a omputer with an 8-bit word length, a paked array is usually not neess ary. In addition, aessing a paked array takes longer beause of the additional alulations neessary to rossreferene indies and parts of memory loations. A paked array must first be UNPACKed before it an be aessed; the omputer does this automatially. For miroomputers, this proedure has little import ane. For that reason, only paked arrays of type BOOLEAN are allowed in Pasal 64. A paked array may be aessed diretly. Format: VAR name:packed ARRAY[0..end value] OF BOOLEAN; The paked array must have a starting value of 0 and must have an ending value whih is 1 less than a multiple of 8. If this is not the ase, the ompiler will automatially round up the ending value. A paked array may be an element

45 Abaus Software PASCAL-64 of another array or a reord, but only the last dimension may be paked. A paked array may be aessed normally, eah element ontaining a value of TRUE or FALSE. No subranges may be formed from paked fields. Eah element requires only one bit, meaning a field of elements requires only 1250 bytes. A paked array is ideal for very large arrays whih have only two possible values. An example an be found in hapter

46 Abaus Software PASCAL-64 Chapter Files In order to work with files, Pasal allows the ommands WRITE, WRITELN, READ, and READLN to be used with devies other than the sreen and keyboard. This is done simiar to using file in BASIC. Before a file an be opened, it must first be delared as a variable. VAR name,devie address,seondary address:file; The devie address and seondary address are the same paraneters that are used in the BASIC OPEN ommand. The OPEN ommand logial file number is replaed by the name. The VAR delaration reserves the name of the data struture FILE whih is used when opening and losing the file as below. The file is atually opened by the RESET statement: RESET (name,"filename,text,et."); The RESET statement an also be replaed with REWRITE. It is not neesssary to use RESET and REWRITE to distinguish between a read and write ommand beause this is done through the seondary address (datasette) or through the text appended to the filename (disk). The RESET statement orresponds to the OPEN ommand in BASIC. The filename is unneessary for many devies (printer) and may be omitted in these ases. The filename may also be replaed with a data blok (string). The other parameters for RESET are already given in the file delaration. A file is losed with the CLOSE statement: CLOSE (name); A file should always be losed before the end of a program so that no data is lost. A file is aesed through the existing input/output ommands (WRITE, WRITELN, READ, READLN). The filename is plaed before the parameter list for any of the statements, so the omputer knows whih file is being aessed. The data is output exatly as it would be on the sreen and an be read in again in a orresponding manner. To read data with READLN, the data must have been written in the orresponding format, i.e. it must have been written with WRITELN

47 Abaus Software PASCAL-64 Example: 10 VAR CHARACTER:CHAR; DISK,8,8:FILE; 20 PRINTER,4,0:FILE; STATUS:INTEGER; 30 BEGIN 40 RESET (DISK,MTESTFILE,S,RM); RESET(PRINTER); 50 REPEAT 60 READ (DISK,CHARACTER); STATUS:= PEEK(144); 70 WRITE (PRINTER,CHARACTER); WRITE (CHARACTER); 80 UNTIL STATUS=64; (* END OF LOOP *) 90 WRITELN; WRITELN ("DONE."); CLOSE (DISK); 100 CLOSE (PRINTER); END. The program reads a file saved on the disk under the name TESTFILE and then prints this on the sreen and printer. Sine we used a variable of type CHAR, this is done in single haraters at a time. 7.2 Error hannel and file status The funtion PEEK(144) returns the file status of the last input or output funtion and orresponds to the BASIC variable ST. If the memory loation 144 ontains a 64, the end of the file was reahed. A file is automatially predelared by Pasal 64 for the disk error hannel: VAR ERROR,8,15:FILE; This delaration need not be written in a program, it is automatially inluded by the ompiler. The error hannel is opened with: RESET (ERROR); Now file messages an be reeived or ommands sent over this file. The error hannel is losed with: CLOSE (ERROR); Remember that losing the error hannel also loses all other files on the disk. The error hannel should only be losed at the end of the program

48 Abaus Software PASCAL Input/output of data bloks As indiated in hapter 6, it is possible to input and output data bloks. Several ases must be distiguished: -The only data bloks whih it makes sense to output to the sreen or printer are those of type CHAH. The data blok will then be printed as a string. A CHR(O) auses the output to ease. -It is also possible to input only data bloks of type CHAR from the keyboard. Pressing the RETURN key indiates that the input is done and the remaining elements are filled with CHR(O). -It is possible to input or output data bloks using the disk and all other devies with devie numbers greater than 7 (suh as a seond disk). The data blok is thereby written or read byte by byte. This also applies to data bloks of type CHAR a CHR(O) is treated as any other harater. Partiularly interesting is the input and output of data by reords or even by entire files with a single statement. Sequential files are not well suited for this sort of aess sine all of the preeding reords must be read before a given reord an be read in. Sequential files do not permit diret aess to their elements. 7.4 Relative files Relative files represent an effiient method of data aess. Beause the disk drive user's manual does not ex plain the use of realtive files in detail, we will begin with a disussion of the priniples of relative files. Pasal allows relative files to be used and worked with with greater ease than does BASIC. In addition, the Pasal data type RECORD may be used with relative files. (The RECORD* statement used for relative files in BASIC 4.0 should not be onfused with the RECORD data type in PASCAL. Note also the temporary distition between a relative reord and a Pasal RECORD) The priniple of relative files is a sequene of sever al data reords. All reords have the same length so that only the number of the reord need be used to allow the disk to find it in the shortest possible time. The entire file need not be read in as is the ase with sequential files. The individual data reord may be written or read in a manner similar to sequential files. Writing and reading may even be done simultaneously it is not neessary to desig nate a relative file as read or write. The length of the

49 Abaus Software PASCAL-64 reord may not be exeeded under any irumstanes, however. If a speifi portion of a data reord is to be aessed, the data pointer may be positioned over individual bytes. The following proedures are used for managing relative files: Creating a relative file: - The file is opened and the length of the data reord is given (max. 254 bytes). - The number of the last data reord of the file is denoted. Writing a reord: - The file is opened if it is not already opened. - The file pointer is positioned to the data reord to be written. If this reord has never been used, the disk will respond with a RECORD NOT PRESENT error. This message an be ignored in this ase. - The data reord is written. Reading a reord: - The file is opened if required. - The file pointer is positioned to the reord to be read. If this reord has never before been written, the error message RECORD NOT PRESENT will be sent over the error hannel, and this may of ourse NOT be ignored. After all of the hanges or additions have been made to a relative file, it must be losed in order to prevent data from being lost. The advantages of relative files are lear: - Diret and therefore faster aess of individual data reords and even individual bytes. - Presevation of the main memory as diret aess memory. - The ability to read and write in the same file. Additional information and uses of relative files and other types of files an be found in the book The Anatomy of I 41 Disk Driven

50 Abaus Software PASCAL Using relative files A relative file must be delared as any other data struture as a variable: VAR name,devie address.seondary address:file; This orresponds to the delaration of sequential files. To open a relative, a variable of type INTEGER (or CHAR) must be present whih ontains the length of the data re ord. In addition, the disk error hannel must be open. RESET (name,"filename,l,",variable); The reord length is replaed with a dash "-" and then by the ontents of the variable. A number may be used diretly, instead of the variable. The filename together with the file type "L" and the dash may be ombined into an array of type CHAR. In a ertain sense, a relative file in Pasal is really a FILE OF RECORD. Beause the organization of rel ative files is handled by the disk drive and not by the omputer, the data type FILE in Pasal 64 requires no fur ther information. A relative file is losed as usual with: CLOSE (filename); The positioning to a reord is done with the statement SEEK: SEEK (name,reord number,byte number); If the byte number is omitted, the first byte will be aessed. The reord number and byte number may also be expressions. The error hannel must be opened before this statement an be used. The desired data reord an now be read or written at the given byte position. To determine the length of a reord, the lengths of the individual basi data types must be summed. When using WRITELN instead of WRITE, an extra byte must be added for the trailing RETURN. The following program demonstrates the use of relative files: 10 VAR DFILE,8,2:FILE; 20 DATA:RECORD CITY:ARRAYfl..12] OF CHAR; ZIP:INTEGER; END; 30 POS,CHOICE,LBN:INTEGER; 40 BEGIN 50 LEN:= 15; RESET (DFILE,"FILE.REL,L,-",LEN); 60 RESET (ERROR); REPEAT 70 WRITE (H2=READ, 1=WRITE, 0=BND? "); READLN (CHOICE); 75 WRITELN ("POSITION? "); READLN (POS); SEEK (DFILE,POS); 80 CASE CHOICE OF

51 Abaus Software PASCAL ; 1: BEGIN READLN (DATA.CITY,DATA.ZIP); 100 WRITELN (DFILE,DATA); END; 110 ; 2: BEGIN READLN (DFILE,DATA); WRITELN (DATA.STAT,DATA.ZIP); END; 120 END; UNTIL CHOICE=0; 130 CLOSE (DFILE); END

52 Abaus Software PASCAL-64 Chapter SBTs The set in Pasal is a olletion of several elements of the same basi type. A set is therefore a data struture like arrays and reords. Eah element of the basi type is either present within a set or absent from it. There is no diret aess to the individual elements of the set, as is possible using the index of an array. It is only possible to determine if an element is present in a set or not. If an element is assigned to a set twie, the ontents of the set will not hange. Several sets may be ombined using the mathematial operators. The data type of a set may be either INTEGER, CHAR, or, sine elements of a user-defined TYPE are internally represented as integers, of a user-defined TYPE. Sine the atual type is only important for output, and sets annot be output, it is not neessary to speify the type of set in Pasal 64. A set may therefore ontain any desired elements of type INTEGER or type CHAR. REAL values will automatially be onverted to integers. A set should only be used for one data type so you may wish to give the data type of set as a omment behind it to remind you. The set de laration is the same as for a basi data type, although the set itself does not represent a basi data type: VAR name:set; A set may be plaed in a delaration wherever a basi data type may be plaed. Sets may be used as elements of arrays and reords. In standard Pasal, the range of values whih may be assigned to a set are limited by most ompilers and must be given in the delaration. The size of the range varies from ompiler to ompiler but is usually between 64 and 256. Sets in Pasal 64 an ontain any of the elements of type INTEGER or CHAR. A set ould ontain both the values and 20000, for example. In spite of this, the maximum number of elements in a set is limited, although not by their value range. If a set is assigned more than 63 ele ments, an OVERFLOW message is given. To determine if an element of a desired data type is in a set, you need only determine if the array index or pointer address is ontained in it. Using this trik, it is possible to make sets of data types other than INTEGER or CHAR. It must be noted that a set does not represent a data blok. In spite of this, sets an be assigned to eah other or passed to subroutines. If sets are to be saved to disk, they must be saved as part of a reord so that the the reord an be output

53 Abaus Software PASCAL Representing sets A number an be given as a variable or as a value diretly in a program. The same applies to sets. A set is represented diretly by listing the set elements and plaing thesein square brakets: [5,4,3,-l,X,Q+l,5 DIV 4,7,8,9,10] or with a set of type CHAR: [tfa",mbm,mctt,mrtt,chr(x),chr(x+l),chr(x+2)] The elements of a set may be the results of expressions. A set without elements is represented as an empty set: It is obvious that set elements will frequently have numerially suessive values. A range of numbers or har aters may be speified by the usual double period. The order of elements in a set is entirely irrelevant. The above examples an also be written: [-l,3..5,7..10,x,q+l,5 DIV 4] ["AM..HC",wRtt,CHR(X)..CHR(X+2)] A set speified in this manner may be manipulated diretly or assigned to a set variable. The following assignments are possible: SBT1:= [1,5,7,9..20] SET2:= [] PUNCTUATION:= [",-,"?",".","!",";",":"] 8.3 Set operations The most important set operator is the operator IN. It determines whether or not an element is present within a set. Format: expression IN set This operator returns a result of type BOOLEAN (true or false) and assumes a plae in the algebrai hierarhy of operators. It is plaed at the same level as the omparison operators. All other set operators have the same hierarhy as their REAL-operator ounterparts. With the help of the operator IN, we have a simple way of replaing a CASE state ment:

54 Abaus Software PASCAL-64 IF A IN ["0".."9"] THEN WRITELN ("DIGIT"); IF A IN PUNCTUATION THEN WRITELN ("PUNCTUATION"); The union of two sets ontains all of the elements of both and is itself of type set.: [l,3]+[2,4,5] is idential to [1.5] In order to add an element to a set, it must first be turned into one itself: SET1:= SET1+[NEWNUMBER]; The differene of two sets is a. set ontaining all of the elements of the first set whih do not appear in the seond: [l,2,5,6]-[4,5,8] yields [1,2,6] The intersetion of two sets onsists of all elements ommon to both: [1,2,5,6]*[4,5,8] yields [5] Set omparisons: -equality of sets SET1=SET2 is TRUE if both sets ontain the same elements, -inequality of sets SET1OSET2 is TRUE if at least one element of one set is not ontained in the other. -inlusion (is ontained in) SETK=SET2 is TRUE if every element of SET1 is also in SET2 (SET1 is a subset of SET2). -inlusion (ontains) SET1>=SET2 is TRUE if eah element of SET2 is also ontained in SET1 (SET1 is a superset of SET2)

55 Abaus Software PASCAL Using sets Sets are useful for avoiding ompliated omparisons usings IF statements. Sets an also be used in their math ematial sense, of ourse. Through the ability to store array indies or pointers, sets an be used to identify elements of more omplex data strutures. The following program searhes entered text for spe ifi groups (sets) of haraters. On of these groups is the speial haraters whih an be defined prior to entering the text. A RETURN ends the speial harater definition and the text input. 20 VAR SPECIAL:SET; 30 SPECIALC,PUNCTC,LETTERC,DIGITC:INTEGER; 40 CHARACTER:CHAR; 50 BEGIN 60 WRITELN ("PLEASE ENTER SPECIAL CHARACTERS"); 65 SPECIAL:= []; SPECIALC:= 0; 70 REPEAT 80 READ (CHARACTER); 85 IF CHARACTEROCHR(13) THEN SPECIAL: = SPECIAL+fCHARACTBR] ; 90 UNTIL CHARACTER=CHR(13); WRITELN; 100 PUNCTC:= 0; LETTERC:= 0; DIGITC:= 0; 110 REPEAT READ (CHARACTER); 120 IF CHARACTER IN SPECIAL THEN SPECIALC:= SPECIALC+1; 130 IF CHARACTER IN ["0".."9"] THEN DIGITC:= DIGITC+1; 140 IF CHARACTER IN [ft.."zw] THEN LETTERC:= LETTERC+1; 150 IF CHARACTER IN [",",". ", M;", ":H,"?","!"] THEN PUNCTC:= PUNCTC+1; 160 UNTIL CHARACTER=CHR(13); WRITELN; 170 WRITELN (SPECIALC,1* SPECIAL CHARACTERS"); 180 WRITELN (LETTERC," LETTERS"); 190 WRITELN (DIGITC," DIGITS"); 200 WRITELN (PUNCTC," PUNCTUATION MARKS"); 210 END

56 Abaus Software PASCAL-64 Chapter Dynami data strutures (linked lists) All of the data strutures we've talked about up to this point, exept for files, are stati, meaning that their size is determined before program exeution and annot be hanged while the program in running. Frequently, however, you do not know the exat size of a data struture before hand, or want to make the most effiient possible use of memory by using a dynami struture, one that alloates only as muh spae as you need at any given moment. To this end, Pasal provides pointers whih we an use to make what are alled linked lists. In a linked list, an element may be inserted or deleted without affeting the position in memory of the other ele ments. With an array, for instane, many of the elements must be shifted in memory in order to insert a new one. Although this is easy to program, as shown in Chapter 6, it requires onsiderably more time to exeute than does a omparable operation performed on a linked list. Lists an represent any data struture, not just arrays where eah element has just one predeessor or suessor. In Pasal, it is possible to determine the memory address of variables and their relationships to eah other from within the program. This is done using pointers. The priniple behind pointers is really quite simple. A variable or data struture is assigned a pointer variable by delaration. In order to be able to aess the data strut ure or its elements, the address of the data struture is first transferred to the pointer variable and then the data struture may be indiretly aessed through the pointer variable. To be able to build a list, the data struture ontains one or more element whih give the address of the predeessor or suessor. In order to aess the suessor of a data struture, the address of the suessor is simply assigned to the pointer variable and the suessor an then be aessed though the pointer. Beause this struture also has a predeessor, it is possible to aess the entire linked list using a single pointer. At least one pointer should be defined whih points to the start or end of the list so that the list an always be searhed from the beginning or end. Beause the list elements are only tied together by pointers, their atual order in memory is unimportant. A new element an be inserted into the list by assigning a new memory loation to the element and hanging two pointers. List elements may also possess more than one predeessor or suessor. Delaration of dynami data strutures:

Chapter 2: Introduction to Maple V

Chapter 2: Introduction to Maple V Chapter 2: Introdution to Maple V 2-1 Working with Maple Worksheets Try It! (p. 15) Start a Maple session with an empty worksheet. The name of the worksheet should be Untitled (1). Use one of the standard

More information

Outline: Software Design

Outline: Software Design Outline: Software Design. Goals History of software design ideas Design priniples Design methods Life belt or leg iron? (Budgen) Copyright Nany Leveson, Sept. 1999 A Little History... At first, struggling

More information

Reading Object Code. A Visible/Z Lesson

Reading Object Code. A Visible/Z Lesson Reading Objet Code A Visible/Z Lesson The Idea: When programming in a high-level language, we rarely have to think about the speifi ode that is generated for eah instrution by a ompiler. But as an assembly

More information

Algorithms for External Memory Lecture 6 Graph Algorithms - Weighted List Ranking

Algorithms for External Memory Lecture 6 Graph Algorithms - Weighted List Ranking Algorithms for External Memory Leture 6 Graph Algorithms - Weighted List Ranking Leturer: Nodari Sithinava Sribe: Andi Hellmund, Simon Ohsenreither 1 Introdution & Motivation After talking about I/O-effiient

More information

Reading Object Code. A Visible/Z Lesson

Reading Object Code. A Visible/Z Lesson Reading Objet Code A Visible/Z Lesson The Idea: When programming in a high-level language, we rarely have to think about the speifi ode that is generated for eah instrution by a ompiler. But as an assembly

More information

ZDT -A Debugging Program for the Z80

ZDT -A Debugging Program for the Z80 ZDT -A Debugging Program for the Z80 il I,, 1651 Third Ave.. New York, N.Y. 10028 (212) 860-o300 lnt'l Telex 220501 ZOT - A DEBUGGING PROGRAM FOR THE ZAO Distributed by: Lifeboat Assoiates 1651 Third Avenue

More information

UCSB Math TI-85 Tutorials: Basics

UCSB Math TI-85 Tutorials: Basics 3 UCSB Math TI-85 Tutorials: Basis If your alulator sreen doesn t show anything, try adjusting the ontrast aording to the instrutions on page 3, or page I-3, of the alulator manual You should read the

More information

Drawing lines. Naïve line drawing algorithm. drawpixel(x, round(y)); double dy = y1 - y0; double dx = x1 - x0; double m = dy / dx; double y = y0;

Drawing lines. Naïve line drawing algorithm. drawpixel(x, round(y)); double dy = y1 - y0; double dx = x1 - x0; double m = dy / dx; double y = y0; Naïve line drawing algorithm // Connet to grid points(x0,y0) and // (x1,y1) by a line. void drawline(int x0, int y0, int x1, int y1) { int x; double dy = y1 - y0; double dx = x1 - x0; double m = dy / dx;

More information

13.1 Numerical Evaluation of Integrals Over One Dimension

13.1 Numerical Evaluation of Integrals Over One Dimension 13.1 Numerial Evaluation of Integrals Over One Dimension A. Purpose This olletion of subprograms estimates the value of the integral b a f(x) dx where the integrand f(x) and the limits a and b are supplied

More information

Analysis of input and output configurations for use in four-valued CCD programmable logic arrays

Analysis of input and output configurations for use in four-valued CCD programmable logic arrays nalysis of input and output onfigurations for use in four-valued D programmable logi arrays J.T. utler H.G. Kerkhoff ndexing terms: Logi, iruit theory and design, harge-oupled devies bstrat: s in binary,

More information

Multiple Assignments

Multiple Assignments Two Outputs Conneted Together Multiple Assignments Two Outputs Conneted Together if (En1) Q

More information

Background/Review on Numbers and Computers (lecture)

Background/Review on Numbers and Computers (lecture) Bakground/Review on Numbers and Computers (leture) ICS312 Mahine-Level and Systems Programming Henri Casanova (henri@hawaii.edu) Numbers and Computers Throughout this ourse we will use binary and hexadeimal

More information

An Event Display for ATLAS H8 Pixel Test Beam Data

An Event Display for ATLAS H8 Pixel Test Beam Data An Event Display for ATLAS H8 Pixel Test Beam Data George Gollin Centre de Physique des Partiules de Marseille and University of Illinois April 17, 1999 g-gollin@uiu.edu An event display program is now

More information

represent = as a finite deimal" either in base 0 or in base. We an imagine that the omputer first omputes the mathematial = then rounds the result to

represent = as a finite deimal either in base 0 or in base. We an imagine that the omputer first omputes the mathematial = then rounds the result to Sientifi Computing Chapter I Computer Arithmeti Jonathan Goodman Courant Institute of Mathemaial Sienes Last revised January, 00 Introdution One of the many soures of error in sientifi omputing is inexat

More information

On - Line Path Delay Fault Testing of Omega MINs M. Bellos 1, E. Kalligeros 1, D. Nikolos 1,2 & H. T. Vergos 1,2

On - Line Path Delay Fault Testing of Omega MINs M. Bellos 1, E. Kalligeros 1, D. Nikolos 1,2 & H. T. Vergos 1,2 On - Line Path Delay Fault Testing of Omega MINs M. Bellos, E. Kalligeros, D. Nikolos,2 & H. T. Vergos,2 Dept. of Computer Engineering and Informatis 2 Computer Tehnology Institute University of Patras,

More information

CleanUp: Improving Quadrilateral Finite Element Meshes

CleanUp: Improving Quadrilateral Finite Element Meshes CleanUp: Improving Quadrilateral Finite Element Meshes Paul Kinney MD-10 ECC P.O. Box 203 Ford Motor Company Dearborn, MI. 8121 (313) 28-1228 pkinney@ford.om Abstrat: Unless an all quadrilateral (quad)

More information

Compilation Lecture 11a. Register Allocation Noam Rinetzky. Text book: Modern compiler implementation in C Andrew A.

Compilation Lecture 11a. Register Allocation Noam Rinetzky. Text book: Modern compiler implementation in C Andrew A. Compilation 0368-3133 Leture 11a Text book: Modern ompiler implementation in C Andrew A. Appel Register Alloation Noam Rinetzky 1 Registers Dediated memory loations that an be aessed quikly, an have omputations

More information

1 The Knuth-Morris-Pratt Algorithm

1 The Knuth-Morris-Pratt Algorithm 5-45/65: Design & Analysis of Algorithms September 26, 26 Leture #9: String Mathing last hanged: September 26, 27 There s an entire field dediated to solving problems on strings. The book Algorithms on

More information

AN INTRODUCTION TO FORTRAN AND NUMERICAL MODELING

AN INTRODUCTION TO FORTRAN AND NUMERICAL MODELING AN INTRODUCTION TO FORTRAN AND NUMERICAL MODELING Dr. L. W. Shwartz Department of Mehanial Engineering University of Delaware September, 2000 INTRODUCTION The first part of this short doument ontains a

More information

Learning Convention Propagation in BeerAdvocate Reviews from a etwork Perspective. Abstract

Learning Convention Propagation in BeerAdvocate Reviews from a etwork Perspective. Abstract CS 9 Projet Final Report: Learning Convention Propagation in BeerAdvoate Reviews from a etwork Perspetive Abstrat We look at the way onventions propagate between reviews on the BeerAdvoate dataset, and

More information

Pipelined Multipliers for Reconfigurable Hardware

Pipelined Multipliers for Reconfigurable Hardware Pipelined Multipliers for Reonfigurable Hardware Mithell J. Myjak and José G. Delgado-Frias Shool of Eletrial Engineering and Computer Siene, Washington State University Pullman, WA 99164-2752 USA {mmyjak,

More information

DECT Module Installation Manual

DECT Module Installation Manual DECT Module Installation Manual Rev. 2.0 This manual desribes the DECT module registration method to the HUB and fan airflow settings. In order for the HUB to ommuniate with a ompatible fan, the DECT module

More information

EXODUS II: A Finite Element Data Model

EXODUS II: A Finite Element Data Model SAND92-2137 Unlimited Release Printed November 1995 Distribution Category UC-705 EXODUS II: A Finite Element Data Model Larry A. Shoof, Vitor R. Yarberry Computational Mehanis and Visualization Department

More information

SAND Unlimited Release Printed November 1995 Updated November 29, :26 PM EXODUS II: A Finite Element Data Model

SAND Unlimited Release Printed November 1995 Updated November 29, :26 PM EXODUS II: A Finite Element Data Model SAND92-2137 Unlimited Release Printed November 1995 Updated November 29, 2006 12:26 PM EXODUS II: A Finite Element Data Model Gregory D. Sjaardema (updated version) Larry A. Shoof, Vitor R. Yarberry Computational

More information

Extracting Partition Statistics from Semistructured Data

Extracting Partition Statistics from Semistructured Data Extrating Partition Statistis from Semistrutured Data John N. Wilson Rihard Gourlay Robert Japp Mathias Neumüller Department of Computer and Information Sienes University of Strathlyde, Glasgow, UK {jnw,rsg,rpj,mathias}@is.strath.a.uk

More information

Gray Codes for Reflectable Languages

Gray Codes for Reflectable Languages Gray Codes for Refletable Languages Yue Li Joe Sawada Marh 8, 2008 Abstrat We lassify a type of language alled a refletable language. We then develop a generi algorithm that an be used to list all strings

More information

Dynamic Programming. Lecture #8 of Algorithms, Data structures and Complexity. Joost-Pieter Katoen Formal Methods and Tools Group

Dynamic Programming. Lecture #8 of Algorithms, Data structures and Complexity. Joost-Pieter Katoen Formal Methods and Tools Group Dynami Programming Leture #8 of Algorithms, Data strutures and Complexity Joost-Pieter Katoen Formal Methods and Tools Group E-mail: katoen@s.utwente.nl Otober 29, 2002 JPK #8: Dynami Programming ADC (214020)

More information

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Test I Solutions

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Test I Solutions Department of Eletrial Engineering and Computer iene MAACHUETT INTITUTE OF TECHNOLOGY 6.035 Fall 2016 Test I olutions 1 I Regular Expressions and Finite-tate Automata For Questions 1, 2, and 3, let the

More information

1. Introduction. 2. The Probable Stope Algorithm

1. Introduction. 2. The Probable Stope Algorithm 1. Introdution Optimization in underground mine design has reeived less attention than that in open pit mines. This is mostly due to the diversity o underground mining methods and omplexity o underground

More information

Series/1 GA File No i=:: IBM Series/ Battery Backup Unit Description :::5 ~ ~ >-- ffi B~88 ~0 (] II IIIIII

Series/1 GA File No i=:: IBM Series/ Battery Backup Unit Description :::5 ~ ~ >-- ffi B~88 ~0 (] II IIIIII Series/1 I. (.. GA34-0032-0 File No. 51-10 a i=:: 5 Q 1 IBM Series/1 4999 Battery Bakup Unit Desription B88 0 (] o. :::5 >-- ffi "- I II1111111111IIIIII1111111 ---- - - - - ----- --_.- Series/1 «h: ",

More information

OvidSP Quick Reference Card

OvidSP Quick Reference Card OvidSP Quik Referene Card Searh in any of several dynami modes, ombine results, apply limits, use improved researh tools, develop strategies, save searhes, set automati alerts and RSS feeds, share results...

More information

COMP 181. Prelude. Intermediate representations. Today. Types of IRs. High-level IR. Intermediate representations and code generation

COMP 181. Prelude. Intermediate representations. Today. Types of IRs. High-level IR. Intermediate representations and code generation Prelude COMP 181 Intermediate representations and ode generation November, 009 What is this devie? Large Hadron Collider What is a hadron? Subatomi partile made up of quarks bound by the strong fore What

More information

Total 100

Total 100 CS331 SOLUTION Problem # Points 1 10 2 15 3 25 4 20 5 15 6 15 Total 100 1. ssume you are dealing with a ompiler for a Java-like language. For eah of the following errors, irle whih phase would normally

More information

A DYNAMIC ACCESS CONTROL WITH BINARY KEY-PAIR

A DYNAMIC ACCESS CONTROL WITH BINARY KEY-PAIR Malaysian Journal of Computer Siene, Vol 10 No 1, June 1997, pp 36-41 A DYNAMIC ACCESS CONTROL WITH BINARY KEY-PAIR Md Rafiqul Islam, Harihodin Selamat and Mohd Noor Md Sap Faulty of Computer Siene and

More information

1. The collection of the vowels in the word probability. 2. The collection of real numbers that satisfy the equation x 9 = 0.

1. The collection of the vowels in the word probability. 2. The collection of real numbers that satisfy the equation x 9 = 0. C HPTER 1 SETS I. DEFINITION OF SET We begin our study of probability with the disussion of the basi onept of set. We assume that there is a ommon understanding of what is meant by the notion of a olletion

More information

HEXA: Compact Data Structures for Faster Packet Processing

HEXA: Compact Data Structures for Faster Packet Processing Washington University in St. Louis Washington University Open Sholarship All Computer Siene and Engineering Researh Computer Siene and Engineering Report Number: 27-26 27 HEXA: Compat Data Strutures for

More information

Divide-and-conquer algorithms 1

Divide-and-conquer algorithms 1 * 1 Multipliation Divide-and-onquer algorithms 1 The mathematiian Gauss one notied that although the produt of two omplex numbers seems to! involve four real-number multipliations it an in fat be done

More information

Dynamic Algorithms Multiple Choice Test

Dynamic Algorithms Multiple Choice Test 3226 Dynami Algorithms Multiple Choie Test Sample test: only 8 questions 32 minutes (Real test has 30 questions 120 minutes) Årskort Name Eah of the following 8 questions has 4 possible answers of whih

More information

'* ~rr' _ ~~ f' lee : eel. Series/1 []J 0 [[] "'l... !l]j1. IBM Series/1 FORTRAN IV. I ntrod uction ...

'* ~rr' _ ~~ f' lee : eel. Series/1 []J 0 [[] 'l... !l]j1. IBM Series/1 FORTRAN IV. I ntrod uction ... ---- --- - ----- - - - --_.- --- Series/1 GC34-0132-0 51-25 PROGRAM PRODUCT 1 IBM Series/1 FORTRAN IV I ntrod ution Program Numbers 5719-F01 5719-F03 0 lee : eel II 11111111111111111111111111111111111111111111111

More information

Graph-Based vs Depth-Based Data Representation for Multiview Images

Graph-Based vs Depth-Based Data Representation for Multiview Images Graph-Based vs Depth-Based Data Representation for Multiview Images Thomas Maugey, Antonio Ortega, Pasal Frossard Signal Proessing Laboratory (LTS), Eole Polytehnique Fédérale de Lausanne (EPFL) Email:

More information

Whole Numbers. Whole Numbers. Solutions. Curriculum Ready.

Whole Numbers. Whole Numbers. Solutions. Curriculum Ready. Whole Numbers Whole Numbers Solutions Curriulum Ready www.mathletis.om Copyright 009 P Learning. All rights reserved. First edition printed 009 in Australia. A atalogue reord for this book is available

More information

Recursion examples: Problem 2. (More) Recursion and Lists. Tail recursion. Recursion examples: Problem 2. Recursion examples: Problem 3

Recursion examples: Problem 2. (More) Recursion and Lists. Tail recursion. Recursion examples: Problem 2. Recursion examples: Problem 3 Reursion eamples: Problem 2 (More) Reursion and s Reursive funtion to reverse a string publi String revstring(string str) { if(str.equals( )) return str; return revstring(str.substring(1, str.length()))

More information

ENGINEERING update FOR 2.0 PRINTGEN. A C Page 1 of 120 PRINTGEN. Engineering Update (DAA -170)

ENGINEERING update FOR 2.0 PRINTGEN. A C Page 1 of 120 PRINTGEN. Engineering Update (DAA -170) o ENGINEERING update FOR 2.0 A-09-01159-01-C Page 1 of 120 Speifiations Subjet to Change. Convergent Tehnologies and NGEN are registered trademarks of Convergent Tehnologies, In. Convergent, CT-DBMS, CT-MAIL,

More information

System-Level Parallelism and Throughput Optimization in Designing Reconfigurable Computing Applications

System-Level Parallelism and Throughput Optimization in Designing Reconfigurable Computing Applications System-Level Parallelism and hroughput Optimization in Designing Reonfigurable Computing Appliations Esam El-Araby 1, Mohamed aher 1, Kris Gaj 2, arek El-Ghazawi 1, David Caliga 3, and Nikitas Alexandridis

More information

What are Cycle-Stealing Systems Good For? A Detailed Performance Model Case Study

What are Cycle-Stealing Systems Good For? A Detailed Performance Model Case Study What are Cyle-Stealing Systems Good For? A Detailed Performane Model Case Study Wayne Kelly and Jiro Sumitomo Queensland University of Tehnology, Australia {w.kelly, j.sumitomo}@qut.edu.au Abstrat The

More information

Introductory Programming, IMM, DTU Systematic Software Test. Software test (afprøvning) Motivation. Structural test and functional test

Introductory Programming, IMM, DTU Systematic Software Test. Software test (afprøvning) Motivation. Structural test and functional test Introdutory Programming, IMM, DTU Systemati Software Test Peter Sestoft a Programs often ontain unintended errors how do you find them? Strutural test Funtional test Notes: Systemati Software Test, http://www.dina.kvl.dk/

More information

Colouring contact graphs of squares and rectilinear polygons de Berg, M.T.; Markovic, A.; Woeginger, G.

Colouring contact graphs of squares and rectilinear polygons de Berg, M.T.; Markovic, A.; Woeginger, G. Colouring ontat graphs of squares and retilinear polygons de Berg, M.T.; Markovi, A.; Woeginger, G. Published in: nd European Workshop on Computational Geometry (EuroCG 06), 0 Marh - April, Lugano, Switzerland

More information

Tavultesoft Keyboard Manager. User s Guide and Reference. Tavultesoft

Tavultesoft Keyboard Manager. User s Guide and Reference. Tavultesoft Tavultesoft Keyboard Manager User s Guide and Referene VERSION 4.0 Tavultesoft This doumentation may be freely opied, but the opyright notie must not be altered or removed. No part of this doumentation

More information

A {k, n}-secret Sharing Scheme for Color Images

A {k, n}-secret Sharing Scheme for Color Images A {k, n}-seret Sharing Sheme for Color Images Rastislav Luka, Konstantinos N. Plataniotis, and Anastasios N. Venetsanopoulos The Edward S. Rogers Sr. Dept. of Eletrial and Computer Engineering, University

More information

The recursive decoupling method for solving tridiagonal linear systems

The recursive decoupling method for solving tridiagonal linear systems Loughborough University Institutional Repository The reursive deoupling method for solving tridiagonal linear systems This item was submitted to Loughborough University's Institutional Repository by the/an

More information

FORTRAN Programming in Nuclear Medicine

FORTRAN Programming in Nuclear Medicine FORTRAN Programming in Nulear Mediine Till Noever Emory University Hospital, Atlanta, Georgia This is the seond in a series of four ontinuing Eduation artiles on omputers in nulear mediine. After studying

More information

Space- and Time-Efficient BDD Construction via Working Set Control

Space- and Time-Efficient BDD Construction via Working Set Control Spae- and Time-Effiient BDD Constrution via Working Set Control Bwolen Yang Yirng-An Chen Randal E. Bryant David R. O Hallaron Computer Siene Department Carnegie Mellon University Pittsburgh, PA 15213.

More information

Adobe Certified Associate

Adobe Certified Associate Adobe Certified Assoiate About the Adobe Certified Assoiate (ACA) Program The Adobe Certified Assoiate (ACA) program is for graphi designers, Web designers, video prodution designers, and digital professionals

More information

And, the (low-pass) Butterworth filter of order m is given in the frequency domain by

And, the (low-pass) Butterworth filter of order m is given in the frequency domain by Problem Set no.3.a) The ideal low-pass filter is given in the frequeny domain by B ideal ( f ), f f; =, f > f. () And, the (low-pass) Butterworth filter of order m is given in the frequeny domain by B

More information

MATH STUDENT BOOK. 12th Grade Unit 6

MATH STUDENT BOOK. 12th Grade Unit 6 MATH STUDENT BOOK 12th Grade Unit 6 Unit 6 TRIGONOMETRIC APPLICATIONS MATH 1206 TRIGONOMETRIC APPLICATIONS INTRODUCTION 3 1. TRIGONOMETRY OF OBLIQUE TRIANGLES 5 LAW OF SINES 5 AMBIGUITY AND AREA OF A TRIANGLE

More information

Automatic Physical Design Tuning: Workload as a Sequence Sanjay Agrawal Microsoft Research One Microsoft Way Redmond, WA, USA +1-(425)

Automatic Physical Design Tuning: Workload as a Sequence Sanjay Agrawal Microsoft Research One Microsoft Way Redmond, WA, USA +1-(425) Automati Physial Design Tuning: Workload as a Sequene Sanjay Agrawal Mirosoft Researh One Mirosoft Way Redmond, WA, USA +1-(425) 75-357 sagrawal@mirosoft.om Eri Chu * Computer Sienes Department University

More information

Parametric Abstract Domains for Shape Analysis

Parametric Abstract Domains for Shape Analysis Parametri Abstrat Domains for Shape Analysis Xavier RIVAL (INRIA & Éole Normale Supérieure) Joint work with Bor-Yuh Evan CHANG (University of Maryland U University of Colorado) and George NECULA (University

More information

Power Factor Controller. Power Factor Controller USER MANUAL

Power Factor Controller. Power Factor Controller USER MANUAL Power Fator Controller Power Fator Controller USER MANUAL Power Fator Controller TABLE OF CONTENTS SECTION GENERAL INFORMATION...0. Symbols...0.2 General Warnings...0.3 Reeipt Control and Contents of the

More information

TLP 350CV Setup Guide

TLP 350CV Setup Guide TLP 350V Setup Guide The Extron TouhLink 3.5 inh able ubby TLP 350V provide users with aess to AV onnetivity using onvenient pullout ables. It also provides simple and versatile onfiguration and ontrol

More information

Page INTRODUCTION PART I - THE PLATO SYSTEM

Page INTRODUCTION PART I - THE PLATO SYSTEM INTRODUCTION PART I - THE PLATO SYSTEM Page A. General Desription - PLATO Ilardware............ B. Relationship of PLATO Hardware to Software....... C. System Operation by Student Input.... D. Relationship

More information

A Unified Subdivision Scheme for Polygonal Modeling

A Unified Subdivision Scheme for Polygonal Modeling EUROGRAPHICS 2 / A. Chalmers and T.-M. Rhyne (Guest Editors) Volume 2 (2), Number 3 A Unified Subdivision Sheme for Polygonal Modeling Jérôme Maillot Jos Stam Alias Wavefront Alias Wavefront 2 King St.

More information

Triangles. Learning Objectives. Pre-Activity

Triangles. Learning Objectives. Pre-Activity Setion 3.2 Pre-tivity Preparation Triangles Geena needs to make sure that the dek she is building is perfetly square to the brae holding the dek in plae. How an she use geometry to ensure that the boards

More information

Algorithms, Mechanisms and Procedures for the Computer-aided Project Generation System

Algorithms, Mechanisms and Procedures for the Computer-aided Project Generation System Algorithms, Mehanisms and Proedures for the Computer-aided Projet Generation System Anton O. Butko 1*, Aleksandr P. Briukhovetskii 2, Dmitry E. Grigoriev 2# and Konstantin S. Kalashnikov 3 1 Department

More information

Exploring the Commonality in Feature Modeling Notations

Exploring the Commonality in Feature Modeling Notations Exploring the Commonality in Feature Modeling Notations Miloslav ŠÍPKA Slovak University of Tehnology Faulty of Informatis and Information Tehnologies Ilkovičova 3, 842 16 Bratislava, Slovakia miloslav.sipka@gmail.om

More information

Definitions Homework. Quine McCluskey Optimal solutions are possible for some large functions Espresso heuristic. Definitions Homework

Definitions Homework. Quine McCluskey Optimal solutions are possible for some large functions Espresso heuristic. Definitions Homework EECS 33 There be Dragons here http://ziyang.ees.northwestern.edu/ees33/ Teaher: Offie: Email: Phone: L477 Teh dikrp@northwestern.edu 847 467 2298 Today s material might at first appear diffiult Perhaps

More information

arxiv: v1 [cs.gr] 10 Apr 2015

arxiv: v1 [cs.gr] 10 Apr 2015 REAL-TIME TOOL FOR AFFINE TRANSFORMATIONS OF TWO DIMENSIONAL IFS FRACTALS ELENA HADZIEVA AND MARIJA SHUMINOSKA arxiv:1504.02744v1 s.gr 10 Apr 2015 Abstrat. This work introdues a novel tool for interative,

More information

COST PERFORMANCE ASPECTS OF CCD FAST AUXILIARY MEMORY

COST PERFORMANCE ASPECTS OF CCD FAST AUXILIARY MEMORY COST PERFORMANCE ASPECTS OF CCD FAST AUXILIARY MEMORY Dileep P, Bhondarkor Texas Instruments Inorporated Dallas, Texas ABSTRACT Charge oupled devies (CCD's) hove been mentioned as potential fast auxiliary

More information

The Happy Ending Problem

The Happy Ending Problem The Happy Ending Problem Neeldhara Misra STATUTORY WARNING This doument is a draft version 1 Introdution The Happy Ending problem first manifested itself on a typial wintery evening in 1933 These evenings

More information

XML Data Streams. XML Stream Processing. XML Stream Processing. Yanlei Diao. University of Massachusetts Amherst

XML Data Streams. XML Stream Processing. XML Stream Processing. Yanlei Diao. University of Massachusetts Amherst XML Stream Proessing Yanlei Diao University of Massahusetts Amherst XML Data Streams XML is the wire format for data exhanged online. Purhase orders http://www.oasis-open.org/ommittees/t_home.php?wg_abbrev=ubl

More information

Calculation of typical running time of a branch-and-bound algorithm for the vertex-cover problem

Calculation of typical running time of a branch-and-bound algorithm for the vertex-cover problem Calulation of typial running time of a branh-and-bound algorithm for the vertex-over problem Joni Pajarinen, Joni.Pajarinen@iki.fi Otober 21, 2007 1 Introdution The vertex-over problem is one of a olletion

More information

PHYS 3437: Computational Methods in Physics, Assignment 2

PHYS 3437: Computational Methods in Physics, Assignment 2 PHYS 3437: Computational Methods in Physis, Assignment 2 Set January 27th due Feb 26th NOTE: This assignment is potentially quite lengthy if you are urrently developing your programming skills. If so,

More information

Partial Character Decoding for Improved Regular Expression Matching in FPGAs

Partial Character Decoding for Improved Regular Expression Matching in FPGAs Partial Charater Deoding for Improved Regular Expression Mathing in FPGAs Peter Sutton Shool of Information Tehnology and Eletrial Engineering The University of Queensland Brisbane, Queensland, 4072, Australia

More information

An Efficient and Scalable Approach to CNN Queries in a Road Network

An Efficient and Scalable Approach to CNN Queries in a Road Network An Effiient and Salable Approah to CNN Queries in a Road Network Hyung-Ju Cho Chin-Wan Chung Dept. of Eletrial Engineering & Computer Siene Korea Advaned Institute of Siene and Tehnology 373- Kusong-dong,

More information

A Partial Sorting Algorithm in Multi-Hop Wireless Sensor Networks

A Partial Sorting Algorithm in Multi-Hop Wireless Sensor Networks A Partial Sorting Algorithm in Multi-Hop Wireless Sensor Networks Abouberine Ould Cheikhna Department of Computer Siene University of Piardie Jules Verne 80039 Amiens Frane Ould.heikhna.abouberine @u-piardie.fr

More information

9 Using Equation Networks

9 Using Equation Networks 9 Using Equation Networks In this chapter Introduction to Equation Networks 244 Equation format 247 Using register address lists 254 Setting up an enable contact 255 Equations displayed within the Network

More information

Connection Guide. Installing the printer locally (Windows) What is local printing? Installing the printer using the Software and Documentation CD

Connection Guide. Installing the printer locally (Windows) What is local printing? Installing the printer using the Software and Documentation CD Page 1 of 7 Connetion Guide Installing the printer loally (Windows) Note: When installing a loally attahed printer, if the operating system is not supported y the Software and Doumentation CD, then the

More information

ERISA Form 8955-SSA 2-D Barcode Standards. Version 1.3 June 7, 2012

ERISA Form 8955-SSA 2-D Barcode Standards. Version 1.3 June 7, 2012 ERISA 8955-SSA 2-D Barode Standards Versi 1.3 June 7, 2012 Plan Years: 2009 2010 2011 History Log Versi Date Summary of Changes Editor 1.0 01/14/2011 Versi 1.0 WBAPSO/CIT 1.1 6/27/2011 - Update Barode

More information

An Optimized Approach on Applying Genetic Algorithm to Adaptive Cluster Validity Index

An Optimized Approach on Applying Genetic Algorithm to Adaptive Cluster Validity Index IJCSES International Journal of Computer Sienes and Engineering Systems, ol., No.4, Otober 2007 CSES International 2007 ISSN 0973-4406 253 An Optimized Approah on Applying Geneti Algorithm to Adaptive

More information

INTRODUCTION 1 AND REVIEW

INTRODUCTION 1 AND REVIEW INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

More information

Torpedo Trajectory Visual Simulation Based on Nonlinear Backstepping Control

Torpedo Trajectory Visual Simulation Based on Nonlinear Backstepping Control orpedo rajetory Visual Simulation Based on Nonlinear Bakstepping Control Peng Hai-jun 1, Li Hui-zhou Chen Ye 1, 1. Depart. of Weaponry Eng, Naval Univ. of Engineering, Wuhan 400, China. Depart. of Aeronautial

More information

CA Agile Requirements Designer 2.x Implementation Proven Professional Exam (CAT-720) Study Guide Version 1.0

CA Agile Requirements Designer 2.x Implementation Proven Professional Exam (CAT-720) Study Guide Version 1.0 Exam (CAT-720) Study Guide Version 1.0 PROPRIETARY AND CONFIDENTIAL INFORMATION 2017 CA. All rights reserved. CA onfidential & proprietary information. For CA, CA Partner and CA Customer use only. No unauthorized

More information

特集 Road Border Recognition Using FIR Images and LIDAR Signal Processing

特集 Road Border Recognition Using FIR Images and LIDAR Signal Processing デンソーテクニカルレビュー Vol. 15 2010 特集 Road Border Reognition Using FIR Images and LIDAR Signal Proessing 高木聖和 バーゼル ファルディ Kiyokazu TAKAGI Basel Fardi ヘンドリック ヴァイゲル Hendrik Weigel ゲルド ヴァニーリック Gerd Wanielik This paper

More information

A Novel Validity Index for Determination of the Optimal Number of Clusters

A Novel Validity Index for Determination of the Optimal Number of Clusters IEICE TRANS. INF. & SYST., VOL.E84 D, NO.2 FEBRUARY 2001 281 LETTER A Novel Validity Index for Determination of the Optimal Number of Clusters Do-Jong KIM, Yong-Woon PARK, and Dong-Jo PARK, Nonmembers

More information

Sparse Certificates for 2-Connectivity in Directed Graphs

Sparse Certificates for 2-Connectivity in Directed Graphs Sparse Certifiates for 2-Connetivity in Direted Graphs Loukas Georgiadis Giuseppe F. Italiano Aikaterini Karanasiou Charis Papadopoulos Nikos Parotsidis Abstrat Motivated by the emergene of large-sale

More information

This fact makes it difficult to evaluate the cost function to be minimized

This fact makes it difficult to evaluate the cost function to be minimized RSOURC LLOCTION N SSINMNT In the resoure alloation step the amount of resoures required to exeute the different types of proesses is determined. We will refer to the time interval during whih a proess

More information

Video Data and Sonar Data: Real World Data Fusion Example

Video Data and Sonar Data: Real World Data Fusion Example 14th International Conferene on Information Fusion Chiago, Illinois, USA, July 5-8, 2011 Video Data and Sonar Data: Real World Data Fusion Example David W. Krout Applied Physis Lab dkrout@apl.washington.edu

More information

CUTTING FORCES AND CONSECUTIVE DEFORMATIONS AT MILLING PARTS WITH THIN WALLS

CUTTING FORCES AND CONSECUTIVE DEFORMATIONS AT MILLING PARTS WITH THIN WALLS Proeedings of the International Conferene on Manufaturing Systems ICMaS Vol. 4, 2009, ISSN 1842-3183 University POLITEHNICA of Buharest, Mahine and Manufaturing Systems Department Buharest, Romania CUTTING

More information

CS:APP2e Web Aside ASM:X87: X87-Based Support for Floating Point

CS:APP2e Web Aside ASM:X87: X87-Based Support for Floating Point CS:APP2e Web Aside ASM:X87: X87-Based Support for Floating Point Randal E. Bryant David R. O Hallaron June 5, 2012 Notie The material in this doument is supplementary material to the book Computer Systems,

More information

Allocating Rotating Registers by Scheduling

Allocating Rotating Registers by Scheduling Alloating Rotating Registers by Sheduling Hongbo Rong Hyunhul Park Cheng Wang Youfeng Wu Programming Systems Lab Intel Labs {hongbo.rong,hyunhul.park,heng..wang,youfeng.wu}@intel.om ABSTRACT A rotating

More information

ICCGLU. A Fortran IV subroutine to solve large sparse general systems of linear equations. J.J. Dongarra, G.K. Leaf and M. Minkoff.

ICCGLU. A Fortran IV subroutine to solve large sparse general systems of linear equations. J.J. Dongarra, G.K. Leaf and M. Minkoff. http://www.netlib.org/linalg/ig-do 1 of 8 12/7/2009 11:14 AM ICCGLU A Fortran IV subroutine to solve large sparse general systems of linear equations. J.J. Dongarra, G.K. Leaf and M. Minkoff July, 1982

More information

Xpander Rack Mount 2 Gen 3 HPC Version User Guide

Xpander Rack Mount 2 Gen 3 HPC Version User Guide Xpander Rak Mount 2 Gen 3 HPC Version User Guide Xpander Rak Mount 2 is a 2U rak mount PCI Express (PCIe) expansion enlosure that enables onnetion of two passively-ooled aelerators to a host omputer. The

More information

CA Test Data Manager 4.x Implementation Proven Professional Exam (CAT-681) Study Guide Version 1.0

CA Test Data Manager 4.x Implementation Proven Professional Exam (CAT-681) Study Guide Version 1.0 Implementation Proven Professional Study Guide Version 1.0 PROPRIETARY AND CONFIDENTIAL INFORMATION 2017 CA. All rights reserved. CA onfidential & proprietary information. For CA, CA Partner and CA Customer

More information

BioTechnology. An Indian Journal FULL PAPER. Trade Science Inc. Improvement of low illumination image enhancement algorithm based on physical mode

BioTechnology. An Indian Journal FULL PAPER. Trade Science Inc. Improvement of low illumination image enhancement algorithm based on physical mode [Type text] [Type text] [Type text] ISSN : 0974-7435 Volume 10 Issue 22 BioTehnology 2014 An Indian Journal FULL PAPER BTAIJ, 10(22), 2014 [13995-14001] Improvement of low illumination image enhanement

More information

Lecture 14. Recursion

Lecture 14. Recursion Leture 14 Reursion Announements for Today Prelim 1 Tonight at 5:15 OR 7:30 A D (5:15, Uris G01) E-K (5:15, Statler) L P (7:30, Uris G01) Q-Z (7:30, Statler) Graded y noon on Sun Sores will e in CMS In

More information

The Minimum Redundancy Maximum Relevance Approach to Building Sparse Support Vector Machines

The Minimum Redundancy Maximum Relevance Approach to Building Sparse Support Vector Machines The Minimum Redundany Maximum Relevane Approah to Building Sparse Support Vetor Mahines Xiaoxing Yang, Ke Tang, and Xin Yao, Nature Inspired Computation and Appliations Laboratory (NICAL), Shool of Computer

More information

BSPLND, A B-Spline N-Dimensional Package for Scattered Data Interpolation

BSPLND, A B-Spline N-Dimensional Package for Scattered Data Interpolation BSPLND, A B-Spline N-Dimensional Pakage for Sattered Data Interpolation Mihael P. Weis Traker Business Systems 85 Terminal Drive, Suite Rihland, WA 995-59-946-544 mike@vidian.net Robert R. Lewis Washington

More information

WORKSHOP 20 CREATING PCL FUNCTIONS

WORKSHOP 20 CREATING PCL FUNCTIONS WORKSHOP 20 CREATING PCL FUNCTIONS WS20-1 WS20-2 Problem Desription This exerise involves reating two PCL funtions that an be used to easily hange the view of a model. The PCL funtions are reated by reording

More information

PathRings. Manual. Version 1.0. Yongnan Zhu December 16,

PathRings. Manual. Version 1.0. Yongnan Zhu   December 16, PathRings Version 1.0 Manual Yongnan Zhu E-mail: yongnan@umb.edu Deember 16, 2014-1 - PathRings This tutorial introdues PathRings, the user interfae and the interation. For better to learn, you will need

More information

Boundary Correct Real-Time Soft Shadows

Boundary Correct Real-Time Soft Shadows Boundary Corret Real-Time Soft Shadows Bjarke Jakobsen Niels J. Christensen Bent D. Larsen Kim S. Petersen Informatis and Mathematial Modelling Tehnial University of Denmark {bj, nj, bdl}@imm.dtu.dk, kim@deadline.dk

More information

C 2 C 3 C 1 M S. f e. e f (3,0) (0,1) (2,0) (-1,1) (1,0) (-1,0) (1,-1) (0,-1) (-2,0) (-3,0) (0,-2)

C 2 C 3 C 1 M S. f e. e f (3,0) (0,1) (2,0) (-1,1) (1,0) (-1,0) (1,-1) (0,-1) (-2,0) (-3,0) (0,-2) SPECIAL ISSUE OF IEEE TRANSACTIONS ON ROBOTICS AND AUTOMATION: MULTI-ROBOT SSTEMS, 00 Distributed reonfiguration of hexagonal metamorphi robots Jennifer E. Walter, Jennifer L. Welh, and Nany M. Amato Abstrat

More information