Board index » delphi » Re: I/O error 103

Re: I/O error 103


2006-03-04 04:25:11 AM
delphi219
Here is aA little variation on the previous. If a file with
the same name is open by WinWord, then the ReWrite
causes the error
"I/O error 32 trying to open C:\Temp\Temp001.TXT".
to pop into the memo box.
Var
FNbr: integer;
Const
EditorPgmPath =
'C:\Program Files\Microsoft Office\Office10\winword.exe';
procedure TForm1.Button5Click(Sender: TObject);
var F: TextFile; stpath1, stpath2: string; iError: integer;
begin
Inc(FNbr);
stPath2 := Format('C:\Temp\Temp%3.3D.TXT',[FNbr]);
AssignFile(F,stpath2);
{$I-}
ReWrite(F);
iError := IoResult;
{$I+}
If iError <>0
then Memo1.Lines.Add(Format
('I/O error %D tring to open %S.',[iError,stPath2]))
// Ex: I/O error 32 trying to open C:\Temp\Temp002.TXT
// Using "C:\>net helpmsg 32" gives
// "The process cannot access the file because it is being
// used by another process."
else
try{finally}
WriteLn(F,'File Path = ' + stPath2);
finally
CloseFile(F);
stpath1 := EditorPgmPath + ' ' + stpath2;
iError := WinExec(PChar(stPath1),SW_SHOWNORMAL);
if iError < 32
then Memo1.Lines.
Add(Format('iError=#%D occurred.',[iError]));
end{finally};
end;
 
 

Re: I/O error 103

John Luetich writes:
Quote
Here's my code. the tables are Paradox but I don't think it makes any
difference

with tblzprntid do begin
tmpprnt1 := fieldbyname('prntID').asInteger;
tmpprnt2 := tmpprnt1 + 1;
edit;
fieldbyname('prntID').asInteger := tmpprnt2;
post;
end;
With this code it is very possible for two computers (or even more) to get
the same number and this would easily explain the error you are seeing.
- Any number of computers could read the current value from the table before
any have incremented and written back the new value.
- therefore any number can end up writing back the same new value and
attempting to use this to write the text file.
- whoever launches Word first wins.
Sticking with Paradox, you need to set Exclusive to true on the TTable and
add calls to Open and Close the table in the above code. Wrap that in a
try/except block and, in the case of an exception, wait a bit and try again.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
"Democracy, without the guarantee of liberty, is merely a method of
selecting tyrants." - Alan Nitikman
 

Re: I/O error 103

I'm getting another annoying error here, after using tstreams for my text
report, and I can not seem to find the cause.
It's a delphi dialog box with the app name on the banner, saying "Record/Key
Deleted", and the app is only passing values to strings, not writing to a
table at all. A refresh doesn't seem to work, either.
Any suggestions?
Thanks
John
"John Herbster" <herb-sci1_at_sbcglobal.net>writes
Quote

"John Luetich" <XXXX@XXXXX.COM>wrote
>I have a database app shared by about 10 people.
>I create a report in a text file, copying fields into
>strings and writeln the strings, and open the text
>file in Word.

>Each text file has a different filename.

I can believe that. <g>

>Yet if one user has one file open in Word, and another tries to open
>another,

Another? Has the writer close the file?

>they get an I/O Error 103.

To find more info on the subject error:
groups.google.com/groups&as_oq=&as_ugroup=borland.public.delphi.*

HTH, JohnH

PS: Maybe it is time to learn about classic databases.





 

Re: I/O error 103

"John Luetich" <XXXX@XXXXX.COM>wrote
Quote
I'm getting another annoying error here, after using tstreams
for my text report, and I can not seem to find the cause.
It's a delphi dialog box with the app name on the banner, saying
"Record/Key Deleted", and the app is only passing values to
strings, not writing to a table at all. A refresh doesn't seem to
work, either. Any suggestions?
Yes, two:
(1) Try stepping through you code, to find where the problem
happens.
(2) With Google Groups, Advanced mode, search for the phrase
"Record/Key Deleted" in borland.public.dephi.*
groups.google.com/groups/search
Rgds, JohnH