Hi!
I write a function that looks like this:
function codigo_tipofact(nro_ingresado: string): string;
var
pcnro_ingresado : pchar;
pre_guion : string;
pcpre_guion : pchar;
post_guion: string;
posicion : Integer;
begin
pcnro_ingresado := pchar(nro_ingresado);
posicion := ansipos('-', pcnro_ingresado);
StrMove(pcpre_guion,pcnro_ingresado,posicion-1);
pre_guion := RightStr('0000' + trim(string(pcpre_guion)),4);
posicion := ansipos('-', pcnro_ingresado);
post_guion:= rightstr(pcnro_ingresado,(length(nro_ingresado) - posicion));
post_guion := RightStr('00000000' + post_guion,8);
result := pre_guion + '-' + post_guion;
end;
The input is some string with a '-' in some position. i have to return de same number but with 4 digit before the '-' and 8 digits after the '-'. ej:
input = '0-1', output = '0000-00000001'
This function works great until today when i try to call it from another function, then i saw that when i input
'0-1' from the calling funtion the ouput is '00%¾-00000001'.
When i watch the variables during a debug i saw that the pcpre_guion variable has this value 0%¾, before i put anything into it. So i don't know how to initialize that variable.
i don't know, may be the whole function is wrong...
help?
I write a function that looks like this:
function codigo_tipofact(nro_ingresado: string): string;
var
pcnro_ingresado : pchar;
pre_guion : string;
pcpre_guion : pchar;
post_guion: string;
posicion : Integer;
begin
pcnro_ingresado := pchar(nro_ingresado);
posicion := ansipos('-', pcnro_ingresado);
StrMove(pcpre_guion,pcnro_ingresado,posicion-1);
pre_guion := RightStr('0000' + trim(string(pcpre_guion)),4);
posicion := ansipos('-', pcnro_ingresado);
post_guion:= rightstr(pcnro_ingresado,(length(nro_ingresado) - posicion));
post_guion := RightStr('00000000' + post_guion,8);
result := pre_guion + '-' + post_guion;
end;
The input is some string with a '-' in some position. i have to return de same number but with 4 digit before the '-' and 8 digits after the '-'. ej:
input = '0-1', output = '0000-00000001'
This function works great until today when i try to call it from another function, then i saw that when i input
'0-1' from the calling funtion the ouput is '00%¾-00000001'.
When i watch the variables during a debug i saw that the pcpre_guion variable has this value 0%¾, before i put anything into it. So i don't know how to initialize that variable.
i don't know, may be the whole function is wrong...
help?