Error changing old Bank data

1

With the help of this answer I was able to edit the data that I enter in the database, but the old data that is already registered, when I try to change the register, the program continues to close by itself and when debugging displays the following message error.

AndifIcontinuedebuggingtheerrorhappenstobe:

IhavebeendebuggingthecodeandtheerrorisoccurringinprocedureSend_ftp,myprocedurelookslikethis:

procedureTfrmCriarArquivo.Envio_ftp(grupo,cliente:string);beginwithFTPdotryUsername:=frmMenu.usuario;Password:=frmMenu.senha;Host:=frmMenu.endereco;Port:=StrtoInt(frmMenu.porta);Connect;tryChangeDir(grupo);exceptFTP.MakeDir(grupo);ChangeDir(grupo);end;tryFTP.Put('dados.ini','dados.ini',false);exceptend;tryChangeDir(grupo+'/'+cliente);exceptFTP.MakeDir(grupo+'/'+cliente);ChangeDir(grupo+'/'+cliente);end;exceptapplication.Terminate;end;tryFTP.Put(cliente+'.xml',cliente+'.xml',False);FTP.Put('Tags'+'_'+cliente+'.txt','Tags'+'_'+cliente+'.txt',false);finallyFTP.Disconnect;end;DeleteFile(cliente+'.xml');DeleteFile('Tags'+'_'+cliente+'.txt');DeleteFile('dados.ini');end;

RememberingthatthisonlyhappenswhenItrytochangetheoldbankrecords.

NewError:

and how did procedure get after the change:

with FTP do try
    Username := frmMenu.usuario;
    Password := frmMenu.senha;
    Host := frmMenu.endereco;
    Port := StrtoInt(frmMenu.porta);
    Connect;
    try
      ChangeDir(grupo);
    except
      FTP.MakeDir(grupo);
      ChangeDir(grupo);
    end;
    try
      FTP.Put('dados.ini', 'dados.ini', false);
    except
    end;
    try
      ChangeDir(grupo + '/' + cliente);
    except
      FTP.MakeDir(grupo + '/' + cliente);
      ChangeDir(grupo + '/' + cliente);
    end;
  except
    application.Terminate;
  end;
    
asked by anonymous 13.01.2017 / 17:30

1 answer

2

EConvertError (the exception indicated in your message) usually happens when trying to convert one value type to another. In your case it's happening because of the line:

StrtoInt(frmMenu.porta)

StrToInt is a method that converts a string to an integer. As commented, frmMenu.porta contains the value '' (empty string). Since the method can not convert '' to a number, this error occurs.

To solve, identify if it is in fact possible to% void be empty.

  • If yes, check the field value before conversion and treat it:

    if frmMenu.porta = '' then
      // Por exemplo, usar uma porta padrão...
      Port := 20
    else
      Port := StrtoInt(frmMenu.porta);
    
  • Otherwise, identify why the frmMenu.porta field is empty and resolve this.
13.01.2017 / 20:18