Txt
olá compnaheiros do forum,
Eu nao estou entendendo o que pode estar causando o erro, uso delphi 7 com firebird e acesso ao banco pelo dbexpress. Este comando abaixo nao esta retornando uma string no tamanho de 35 e sim 40 (Char) que é o tamanho definido no banco, o outro 30 vem tambem com 40. O que pode estar acontecendo?
Write (MAGNET, Format ( ´¬-35s´, [ Cds_EmpresaNOME_EMP.Value ] ) );
Write (MAGNET, Format ( ´¬-30s´, [ (CDS_EmpresaCIDADE_EMP.Value) ] ) );
Segue o codigo abaixo:
Var
MAGNET : TextFile;
MAGNET_ARQ : String;
begin
inherited;
if MessageDlg( ´Confirma geração do SINTEGRA?´, mtConfirmation, [mbNo, mbYes], 0 ) <> mrYes
Then Exit;
SBExportar.Enabled := False;
SBFechar.Enabled := False;
Screen.Cursor := crSQLWait;
Cds_Conhecimento.Close;
cds_Conhecimento.Params[0].Value := CxDateEdit1.Date;
cds_Conhecimento.Params[1].Value := CxDateEdit2.Date;
cds_Conhecimento.Params[2].Value := EmpresaCODIGO_EMP.Value;
Cds_Conhecimento.Open;
Cds_Entrada.Open;
DecodeDate(date(), Ano, Mes, Dia);
MAGNET_ARQ := lblDiretorio.caption + ´\´ + ´Magnet_´ + FormatFloat( ´0000´, ANO ) + FormatFloat( ´00´, MES ) + FormatFloat( ´00´, DIA) + ´.TXT´;
DeleteFile (MAGNET_ARQ);
AssignFile (MAGNET, MAGNET_ARQ);
if not FileExists(MAGNET_ARQ) then
Begin
Rewrite(MAGNET, MAGNET_ARQ);
End;
Write (MAGNET, ´10´ );
Write (MAGNET, Format ( ´¬-14s´, [ Cds_EmpresaCNPJ_EMP.AsString ] ) );
Write (MAGNET, Format ( ´¬-14s´, [ Cds_EmpresaINSCR_EST_EMP.AsString ] ) );
Write (MAGNET, Format ( ´¬-35s´, [ Cds_EmpresaNOME_EMP.Value ] ) );
Write (MAGNET, Format ( ´¬-30s´, [ (CDS_EmpresaCIDADE_EMP.Value) ] ) );
Write (MAGNET, Format ( ´¬-02s´, [ Cds_EmpresaABREVIAT_UF.Value ] ) );
Write (MAGNET, Format ( ´¬-10s´, [ CDS_EmpresaFAX_EMP.AsString ] ) );
DecodeDate(cxDateEdit1.Date, Ano, Mes, Dia);
Write (MAGNET, FormatFloat ( ´0000´, Ano ) );
Write (MAGNET, FormatFloat ( ´00´, Mes ) );
Write (MAGNET, FormatFloat ( ´00´, Dia ) );
DecodeDate(cxDateEdit2.Date, Ano, Mes, Dia);
Write (MAGNET, FormatFloat ( ´0000´, Ano ) );
Write (MAGNET, FormatFloat ( ´00´, Mes ) );
Write (MAGNET, FormatFloat ( ´00´, Dia ) );
Texto := ComboBox2.Items.Strings [ComboBox2.ItemIndex];
Write (MAGNET, Format ( ´¬-01s´, [ Texto ] ) );
Texto := ComboBox1.Items.Strings [ComboBox2.ItemIndex];
Write (MAGNET, Format ( ´¬-01s´, [ Texto ] ) );
Texto := ComboBox1.Items.Strings [ComboBox3.ItemIndex];
Write (MAGNET, Format ( ´¬-01s´, [ Texto ] ) );
WriteLn (MAGNET);
Eu nao estou entendendo o que pode estar causando o erro, uso delphi 7 com firebird e acesso ao banco pelo dbexpress. Este comando abaixo nao esta retornando uma string no tamanho de 35 e sim 40 (Char) que é o tamanho definido no banco, o outro 30 vem tambem com 40. O que pode estar acontecendo?
Write (MAGNET, Format ( ´¬-35s´, [ Cds_EmpresaNOME_EMP.Value ] ) );
Write (MAGNET, Format ( ´¬-30s´, [ (CDS_EmpresaCIDADE_EMP.Value) ] ) );
Segue o codigo abaixo:
Var
MAGNET : TextFile;
MAGNET_ARQ : String;
begin
inherited;
if MessageDlg( ´Confirma geração do SINTEGRA?´, mtConfirmation, [mbNo, mbYes], 0 ) <> mrYes
Then Exit;
SBExportar.Enabled := False;
SBFechar.Enabled := False;
Screen.Cursor := crSQLWait;
Cds_Conhecimento.Close;
cds_Conhecimento.Params[0].Value := CxDateEdit1.Date;
cds_Conhecimento.Params[1].Value := CxDateEdit2.Date;
cds_Conhecimento.Params[2].Value := EmpresaCODIGO_EMP.Value;
Cds_Conhecimento.Open;
Cds_Entrada.Open;
DecodeDate(date(), Ano, Mes, Dia);
MAGNET_ARQ := lblDiretorio.caption + ´\´ + ´Magnet_´ + FormatFloat( ´0000´, ANO ) + FormatFloat( ´00´, MES ) + FormatFloat( ´00´, DIA) + ´.TXT´;
DeleteFile (MAGNET_ARQ);
AssignFile (MAGNET, MAGNET_ARQ);
if not FileExists(MAGNET_ARQ) then
Begin
Rewrite(MAGNET, MAGNET_ARQ);
End;
Write (MAGNET, ´10´ );
Write (MAGNET, Format ( ´¬-14s´, [ Cds_EmpresaCNPJ_EMP.AsString ] ) );
Write (MAGNET, Format ( ´¬-14s´, [ Cds_EmpresaINSCR_EST_EMP.AsString ] ) );
Write (MAGNET, Format ( ´¬-35s´, [ Cds_EmpresaNOME_EMP.Value ] ) );
Write (MAGNET, Format ( ´¬-30s´, [ (CDS_EmpresaCIDADE_EMP.Value) ] ) );
Write (MAGNET, Format ( ´¬-02s´, [ Cds_EmpresaABREVIAT_UF.Value ] ) );
Write (MAGNET, Format ( ´¬-10s´, [ CDS_EmpresaFAX_EMP.AsString ] ) );
DecodeDate(cxDateEdit1.Date, Ano, Mes, Dia);
Write (MAGNET, FormatFloat ( ´0000´, Ano ) );
Write (MAGNET, FormatFloat ( ´00´, Mes ) );
Write (MAGNET, FormatFloat ( ´00´, Dia ) );
DecodeDate(cxDateEdit2.Date, Ano, Mes, Dia);
Write (MAGNET, FormatFloat ( ´0000´, Ano ) );
Write (MAGNET, FormatFloat ( ´00´, Mes ) );
Write (MAGNET, FormatFloat ( ´00´, Dia ) );
Texto := ComboBox2.Items.Strings [ComboBox2.ItemIndex];
Write (MAGNET, Format ( ´¬-01s´, [ Texto ] ) );
Texto := ComboBox1.Items.Strings [ComboBox2.ItemIndex];
Write (MAGNET, Format ( ´¬-01s´, [ Texto ] ) );
Texto := ComboBox1.Items.Strings [ComboBox3.ItemIndex];
Write (MAGNET, Format ( ´¬-01s´, [ Texto ] ) );
WriteLn (MAGNET);
Emrinfo
Curtidas 0
Respostas
Massuda
12/04/2006
Experimente fazer...
Write (MAGNET, Format ( ´¬-35s´, [ Trim(Cds_EmpresaNOME_EMP.Value) ] ) );
GOSTEI 0
Emrinfo
12/04/2006
Obrigado, Massuda tem hora que o mais logico ta na sua frente e voce acha que pode ser outra coisa e da alguma vacilada, mas ira isto mesmo no mais agradecido.
GOSTEI 0