OBJECTIVE:
Download a stock datafile using the WGET program and then append to it.
_________________________________________________________
PROBLEM:
Cannot determine when file is ready for appending.
_________________________________________________________
DISCUSSION:
I use ShellExecute to run WGET as follows:
wgetString := PChar ('-O ' +
wgetFileName +
' +
's=' + symbol +
'&a=' + IntToStr (fromMonth) +
'&b=' + IntToStr (fromDay ) +
'&c=' + IntToStr (fromYear ) +
'&d=' + IntToStr ( toMonth) +
'&e=' + IntToStr ( toDay ) +
'&f=' + IntToStr ( toYear ) +
'&g=d' +
'&q=q' +
'&y=0' +
'&z=f' +
'&x=.csv');
errorcode := SHELLexecute ( Form1.Handle,
'open',
PChar('c:\wget.exe'),
wgetString,
nil,
sw_shownormal);
I append using the following simple approach:
AssignFile (wgetFile, wgetFileName );
Append (wgetFile);
WHILE NOT Eof (dataFile) DO
BEGIN
ReadLn (dataFile, nextLine);
WriteLn (wgetFile, nextLine);
END;
Methods tried to determine if the file, wgetFileName, exists:
1) Test for assignment of ShellExecute errorcode.
2) Test for FileExists (wgetFileName) = TRUE.
Both methods are satisfied BEFORE wgetFileName is ready for appending.
My guess is that the file exists while it is being written to. So what test do you use to determine that writing is complete?
Of course that is only a guess.
Thanks in advance.
Tom
Download a stock datafile using the WGET program and then append to it.
_________________________________________________________
PROBLEM:
Cannot determine when file is ready for appending.
_________________________________________________________
DISCUSSION:
I use ShellExecute to run WGET as follows:
wgetString := PChar ('-O ' +
wgetFileName +
' +
's=' + symbol +
'&a=' + IntToStr (fromMonth) +
'&b=' + IntToStr (fromDay ) +
'&c=' + IntToStr (fromYear ) +
'&d=' + IntToStr ( toMonth) +
'&e=' + IntToStr ( toDay ) +
'&f=' + IntToStr ( toYear ) +
'&g=d' +
'&q=q' +
'&y=0' +
'&z=f' +
'&x=.csv');
errorcode := SHELLexecute ( Form1.Handle,
'open',
PChar('c:\wget.exe'),
wgetString,
nil,
sw_shownormal);
I append using the following simple approach:
AssignFile (wgetFile, wgetFileName );
Append (wgetFile);
WHILE NOT Eof (dataFile) DO
BEGIN
ReadLn (dataFile, nextLine);
WriteLn (wgetFile, nextLine);
END;
Methods tried to determine if the file, wgetFileName, exists:
1) Test for assignment of ShellExecute errorcode.
2) Test for FileExists (wgetFileName) = TRUE.
Both methods are satisfied BEFORE wgetFileName is ready for appending.
My guess is that the file exists while it is being written to. So what test do you use to determine that writing is complete?
Of course that is only a guess.
Thanks in advance.
Tom