| «‹ March 2015 ›» | | S | M | T | W | T | F | S | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | 8 | 9 | 10 | 11 | 12 | 13 | 14 | | 15 | 16 | 17 | 18 | 19 | 20 | 21 | | 22 | 23 | 24 | 25 | 26 | 27 | 28 | | 29 | 30 | 31 | |
|
2009 年 9 月 11 日 星期五  |
| Text File |
分類: Programming Language |
High-level Programming Language (Pascal)
Text File
- is a collection of alphanumeric characters
- is ended with the character <eof> (end-of-file)
- all file_variables should be declared at the var declaration
e.g var infile, outfile : text;
Relevant Procedures
- assign (file_variable, 'external_file')
- is used to associate a file variable with the external file
- e.g. assign (infile, 'DataIn.txt');
- establish a link between the file_variable (infile) and the external_file (DataIn.txt)
- reset (file_vaiable)
- to open a file for input (reading)
- e.g reset (infile);
- to open the file (infile) for input
- set the file pointer to the beginning of a file
- file pointer is a marker that points to the next character to be processed in a file
- read (file_vaiable, input_list) / readln (file_vaiable, input_list)
- input_list is used to store the data
- types of input_list variables should be integer, real, char, string
- rewrite (file_variable)
- to open a file for output (writing)
- e.g rewrite (outfile);
- to open the file (outfile) for output
- set the file pointer to the beginning of a file
- if the external file (DataOut.txt) does not exist then an empty file (DataOut.txt) will be created
- if the file already exists and is not an empty file then rewrite statement will erase all the data in the file (DataOut.txt)
- write (file_variable, output_list) / writeln (file_variable, output_list)
- close (file_variable)
- to close the file
- force the buffer to proceed the transfer (writing the data into the external file)
- all opened input files and output files must be closed if they will not be reused in the program
Relevant Function
- eof (file_variable)
- to determine whether the character is an end-of-file character
- any attempt to read data beyond the <eof> will cause a run-time error
|
| Arrays |
分類: Programming Language |
High-level Programming Language (Pascal) Arrays
- structured data type (e.g. array and record)
- can store a collection of data items of the same type ......
(閱讀全文)
|
| String Procedures |
分類: Programming Language |
High-level Programming Language (Pascal) String Procedures
- val (<InStr>, <Num>, <ErrorCode>)
- converts a <InStr> to its numeric equivalent
- if the......
(閱讀全文) |
| String Functions |
分類: Programming Language |
High-level Programming Language (Pascal) String Functions
- length (<InStr>)
- return the length of a <InStr> (i.e. the number of characters in the string)
- for ......
(閱讀全文)
|
| String Operation |
分類: Programming Language |
High-level Programming Language (Pascal) Basic Operations on Strings Assignment
- for example,
Name := 'Chan Tai Man';
Class := 'F4A';
Address := 'Rm&......
(閱讀全文)
|
|