如何從文字檔跳行讀取字串 |
尚未結案
|
SSDD
一般會員 發表:3 回覆:0 積分:0 註冊:2005-09-30 發送簡訊給我 |
|
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
procedure TForm1.FormActivate(Sender: TObject); var AppIni: TIniFile; SecLst: TStringList; i: Integer; begin SecLst := TStringList.Create; AppIni := TIniFile.Create('Your_File_Path'); AppIni.ReadSections(SecLst); for i:=0 to SecLst.Count-1 do begin if Copy(SecLst[i],1,5)='Users' then Save Copy(SecLst[i],7,5) to Array.... end; AppIni.Free; SecLst.Free; end; |
christie
資深會員 發表:30 回覆:299 積分:475 註冊:2005-03-25 發送簡訊給我 |
First, New a Console Program(Console Application)
program Cvt001; {$APPTYPE CONSOLE} uses SysUtils, Strutils; const arraysize=5120; var f : textfile; str:string; a_chr : array[1..arraysize] of char; i : integer; begin //Initial array a_chr <= Insert code here assignfile(f, paramstr(1)); // <==文字檔名 reset(f); while not eof(f) do begin readln(f,str); if pos('[Users_' ,str)>0 then begin str:=copy(str,pos('[Users_', str) 7,4); a_chr[strtoint(str)] :='1'; writeln(str); end end; closefile(f); for i:=1 to arraysize do if a_chr[i] = '1' then writeln('Here we got:' inttostr(i)); end.執行: CVT001.exe 文字檔名 Try it!
------
What do we live for if not to make life less difficult for each other? |
Ktop_Robot
站務副站長 發表:0 回覆:3511 積分:0 註冊:2007-04-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |