Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 More on Readln:numerical values Note: ENTER key counts sends a carriage return and a line feed to the computer definition: “white space”: space, tab,

Similar presentations


Presentation on theme: "1 More on Readln:numerical values Note: ENTER key counts sends a carriage return and a line feed to the computer definition: “white space”: space, tab,"— Presentation transcript:

1 1 More on Readln:numerical values Note: ENTER key counts sends a carriage return and a line feed to the computer definition: “white space”: space, tab, carriage return, line feed white space is used to delimit integers and reals

2 2 Read vs. Readln Readln is like Writeln: After the command is complete, the program’s “input or output pointer” moves to the next line –Writeln: next output placed on the next line –Readln: next input comes from the next line (this means the rest of the input on the original line will be ignored)

3 3 Read vs. Readln (con’t) Read is like Write: After the command is complete, the program’s “input or output pointer” stays on the same line –Write: next output placed immediately to the right of previous output –Read: next input comes from the next (on the right) character that was entered by user (note: input is not always entered by a user)

4 4 Reading Characters No delimiters can be used because white space characters are valid characters ENTER key is read as two characters: –carriage return –line feed

5 5 We will skip section 4.6

6 6 Reading Strings Use readln for strings - NEVER use read readln reads the whole line except CR/LF If the number of characters in the string is less than the length of the string variable, the entire string is assigned to the variable. If the number of characters in the string is more than the length of the string variable, the computer will assign as many characters as can fit in the variable beginning with the first character

7 7 Reading strings and numbers together If you need to read both strings and numbers in the same line, you should read the numbers first.

8 8 Buffer definitions Whenever a read or readln is executed and you type a line of data terminated by hitting ENTER, that line, along with the CR/LF end of line marker is stored as characters in a series of memory locations called the input buffer. –Remember CR and LF are stored as two separate characters

9 9 Pointer While data is in the buffer, the program keeps track of the location it will read the next data item from. After read is used to read data, the pointer points to the character immediately to the right of the last character used. Readln sets the pointer to the first character in the next line.

10 10 Using Units Unit: A group of compiled procedures, along with the definitions and declarations they use. Standard Units: Predefined units that come with the Turbo Pascal compiler

11 11 Standard Units Crt: screen and keyboard procedures DOS: allows use of DOS commands in program System: (automatically included) standard functions and procedure Printer: printer functions and procedures Overlay, Graph: we will not use


Download ppt "1 More on Readln:numerical values Note: ENTER key counts sends a carriage return and a line feed to the computer definition: “white space”: space, tab,"

Similar presentations


Ads by Google