關於Read你一些問題!!! |
答題得分者是:pceyes
|
with
一般會員 ![]() ![]() 發表:6 回覆:5 積分:2 註冊:2008-06-25 發送簡訊給我 |
|
pceyes
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
Read reads data from a file.
Unit System Category text file routines Delphi syntax: Typed files: procedure Read(F , V1 [, V2,...,Vn ] ); Text files: procedure Read( [ var F: Text; ] V1 [, V2,...,Vn ] ); Description The Read procedure can be used in Delphi code in the following ways. For typed files, it reads a file component into a variable. For text files, it reads one or more values into one or more variables. With a type string variable: Read reads all characters up to, but not including, the next end-of-line marker or until Eof(F) becomes true; it does not skip to the next line after reading. If the resulting string is longer than the maximum length of the string variable, it is truncated. After the first Read, each subsequent Read sees the end-of-line marker and returns a zero-length string. Use multiple Readln calls to read successive string values. When the extended syntax is enabled, Read can read null-terminated strings into zero-based character arrays. With a type character variable: Read reads one character from the file and assigns it to the variable. If CRLF mode is enabled and Eof(F) was true before Read was executed, the value Chr(26) (a Ctrl-Z character) is assigned to the variable. (To enable CRLF mode, use SetLineBreakStyle.) With type integer or type real variables: Read skips any blanks, tabs, or end-of-line markers preceding the numeric string. If the numeric string does not conform to the expected format, an I/O error occurs; otherwise, the value is assigned to the variable. The next Read starts with the blank, tab, or end-of-line marker that terminated the numeric string. example : var F1, F2: TextFile; Ch: Char; begin if OpenDialog1.Execute then begin AssignFile(F1, OpenDialog1.Filename); Reset(F1); if SaveDialog1.Execute then begin AssignFile(F2, SaveDialog1.Filename); Rewrite(F2); while not Eof(F1) do begin Read(F1, Ch); Write(F2, Ch); end; CloseFile(F2); end; CloseFile(F1); end; end;
------
努力會更接近成功 |
with
一般會員 ![]() ![]() 發表:6 回覆:5 積分:2 註冊:2008-06-25 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |