ICT
the blog for ICT
ken013194
暱稱: ホロ
性別: 男
國家: 香港
地區: 葵青區
« March 2015 »
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
293031
最新文章
Text File
Arrays
String Procedures
String Functions
String Operation
文章分類
全部 (23)
Programming Language (23)
訪客留言
最近三個月尚無任何留言
每月文章
日誌訂閱
尚未訂閱任何日誌
好友名單
尚無任何好友
網站連結
尚無任何連結
最近訪客
最近沒有訪客
日誌統計
文章總數: 23
留言總數: 0
今日人氣: 0
累積人氣: 45
站內搜尋
RSS 訂閱
RSS Feed
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&......

    (閱讀全文)