Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TryGetFileLine(const FileName: string; Index: Integer; out Line: string): Boolean;
- var
- FileLines: TArrayOfString;
- begin
- // the function succeed when the file can be loaded and the count of lines is
- // greater than the requested line index (it is 0 based index, hence the line
- // count must be greater)
- Result := LoadStringsFromFile(FileName, FileLines) and (GetArrayLength(FileLines) > Index);
- // if the above succeeded, return the file line of the requested index to the
- // output parameter
- if Result then
- Line := FileLines[Index];
- end;
- function GetFirstFileLine(const FileName, Default: string): string;
- begin
- if not TryGetFileLine(FileName, 0, Result) then
- Result := Default;
- end;
- ...
- procedure DirEditChange(Sender: TObject);
- begin
- ...
- L2Ver2.Caption := GetFirstFileLine(FilePath, 'N/A');
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement