I have a simple bbs application where I am scripting the login / pw and uploading and downloading of files.
Sorry I meant to also include the error is ocurring in TVACustomComm.WriteBuffer;
If you do not set comm = nil in the TvaTerminal, the terminal will show the file data being received.
It is unclear how you get the "List index out of bounds" exception. If a problem persists, please provide some sample source code so we can investigate this issue here.
This is the vaWaitMsg event:
begin
TermMsg('Index: '+IntToStr(Index));
case Index of
Prompt_Logon: begin
vaWaitMsg.Active := False;
FLastOperation := OPER_LOGON;
vaWaitMsg.Active := True;
TermMsg('Entering Login');
vaComm.WriteText(GetFieldValue('ClaimLogin')+#13);
end;
Prompt_Password: begin
vaWaitMsg.Active := False;
FLastOperation := OPER_PASSWORD;
vaWaitMsg.Active := True;
TermMsg('Entering Password');
vaComm.WriteText(GetFieldValue('ClaimPassword')+#13);
end;
Prompt_MainPrompt: begin
vaWaitMsg.Active := False;
case FLastOperation of
OPER_PASSWORD: begin
if ClaimsToSend(PTranRecArray) then begin
FLastOperation := OPER_START_SEND;
vaWaitMsg.Active := True;
TermMsg('Press 1');
vaComm.WriteText('1'+#13);
end else begin
FLastOperation := OPER_RECEIVE;
vaWaitMsg.Active := True;
TermMsg('Press 2');
vaComm.WriteText('2'+#13);
end;
end;
//After sending file
OPER_CONTINUE: begin
FLastOperation := OPER_RECEIVE;
vaWaitMsg.Active := True;
TermMsg('Press 2');
vaComm.WriteText('2'+#13);
end;
OPER_RECEIVE, OPER_RECEIVING: begin
FLastOperation := OPER_LOGOFF;
TermMsg('Logging Off');
vaComm.WriteText('LO'+#13);
end;
end;
end;
Prompt_Complete: begin
vaWaitMsg.Active := False;
case FLastOperation of
OPER_SENDING: begin
FLastOperation := OPER_CONTINUE;
TermMsg('Entering to continue');
vaComm.WriteText(#13);
end;
end;
end;
Prompt_StartTrans: begin
vaWaitMsg.Active := False;
case FLastOperation of
OPER_RECEIVE,OPER_RECEIVING: begin
FLastOperation := OPER_RECEIVING;
vaTerminal.Comm := nil;
vaZModem.Mode := tmDownLoad;
//vaWaitMsg.Active := True;
TermMsg('Starting to receive');
try
vaZModem.Execute();
except
end;
end;
OPER_START_SEND: begin
vaWaitMsg.Active := False;
FLastOperation := OPER_SENDING;
vaTerminal.Comm := nil;
vaZModem.Mode := tmUpload;
vaZModem.Files.Add(PTranRecArray^[Low(PTranRecArray^)].ClaimFile);
TermMsg('Starting Upload');
try
vaZModem.Execute();
except
//Eat exception
end;
end;
end;
end;
end;
It is very difficult to guess from this code snippet what is exactly happening.
Can it be there is still data receiving when you set VaTerminal.Comm = nil?
The issue seemed to be with setting the comm property to nil inside of the TVaWaitMsg event. Because the event had not completed it still beleived that the comm property was set and this caused an index out of bounds error.
begin
Sleep(1500); //Pause for 1.5 seconds
vaTerminal.Comm := nil;
vaZModem.Mode := tmUpload;
vaZModem.Files.Add(PTranRecArray^[Low(PTranRecArray^)].ClaimFile);
TermMsg('Starting Upload');
vaZModem.Execute();
end;
Thanks for informing