Erro na DLL que criei...e agora ???
Eu criei a Dll abaixo para formatar campos de data. Alguém saberia me dizer porque quando eu coloca 4 ou 5 caracteres no campo que eu quero formatar ele dá. Invalid Pointer Operation. Porém seu eu colocar qualquer outra quantidade de caracteres, funciona perfeitamente.
library Util;
uses
SysUtils,
Classes;
{$R *.res}
Function Datar(Texto : string):string; export;
Var
i:integer;
Texto_f, comp, temp : string;
Begin
comp := DateToStr(Date);
If (Texto <> ´´) then
Begin
For i := 1 to Length(Texto) do //retira as barras da string
If (Texto[i] <> ´/´) then
Texto_f := Texto_f + Texto[i];
For i := 1 to Length(Texto_f) do
Begin
If (i = 3) or (i = 5) then
temp := temp + ´/´;
Temp := Temp + Texto_f[i];
End;
If Length(Temp) < 11 then
For i:= (length(Temp) + 1) to 11 do
Temp := Temp + comp[i];
End;
Result := Temp;
end;
exports
Datar;
begin
end.
:shock:
library Util;
uses
SysUtils,
Classes;
{$R *.res}
Function Datar(Texto : string):string; export;
Var
i:integer;
Texto_f, comp, temp : string;
Begin
comp := DateToStr(Date);
If (Texto <> ´´) then
Begin
For i := 1 to Length(Texto) do //retira as barras da string
If (Texto[i] <> ´/´) then
Texto_f := Texto_f + Texto[i];
For i := 1 to Length(Texto_f) do
Begin
If (i = 3) or (i = 5) then
temp := temp + ´/´;
Temp := Temp + Texto_f[i];
End;
If Length(Temp) < 11 then
For i:= (length(Temp) + 1) to 11 do
Temp := Temp + comp[i];
End;
Result := Temp;
end;
exports
Datar;
begin
end.
:shock:
Anderson.oberdan
Curtidas 0
Respostas
Fabioastra
21/02/2003
na hora de enviar o parametro para a dll tente converte-lo para pchar
Pchar(parametro) e na função declare como pchar tb provavelmente funcionará
Falow
Pchar(parametro) e na função declare como pchar tb provavelmente funcionará
Falow
GOSTEI 0
Anderson.oberdan
21/02/2003
O erro desapareceu, porém com ele também se foi meu resultado, ou seja, agora a função não retorna nada.
Eu mudei todas as declarações de String para Pchar.
Eu mudei todas as declarações de String para Pchar.
GOSTEI 0
Anderson.oberdan
21/02/2003
Valeu amigo deu certo agora, é que eu tinha mudado o cabeçalho da função apenas na dll e não no projeto.
Abraços.
Abraços.
GOSTEI 0
Alphablend
21/02/2003
For i := 1 to Length(Texto_f) do
Begin
If (i = 3) or (i = 5) then <<== o erro esta aki
temp := temp + ´/´;
Temp := Temp + Texto_f[i]; <<== NAUM DEVERIA TER UM ELSE AKI
End;
========================
FICARIA ASSIM !!!!!!
For i := 1 to Length(Texto_f) do
Begin
If (i = 3) or (i = 5) then
temp := temp + ´/´
ELSE
Temp := Temp + Texto_f[i];
End;
FALOU !!!!!!!
Begin
If (i = 3) or (i = 5) then <<== o erro esta aki
temp := temp + ´/´;
Temp := Temp + Texto_f[i]; <<== NAUM DEVERIA TER UM ELSE AKI
End;
========================
FICARIA ASSIM !!!!!!
For i := 1 to Length(Texto_f) do
Begin
If (i = 3) or (i = 5) then
temp := temp + ´/´
ELSE
Temp := Temp + Texto_f[i];
End;
FALOU !!!!!!!
GOSTEI 0