mám funkci která slouží k hledání v poli znaků, při ladění jsem narazil na to že přesto že se dvě hodnoty rovnají, podmínka je vyhodnotí jako nestejné.
jde konkrétně o find[slovo]=buffer[data+slovo]
Zde je ta fuknkce, znak » v programu naznacuje misto kde momentalne stoji debugger.
buffer: array[0..1024*128] of char;
kde na od 4 mista je napis 'R','A','I','N','B','O','F'
Function TRaw_file.search(find:string;pos:longint=0):longint; {prohleda soubor
var data,slovo,score: longint; //data pozice v datech, slovo pozice ve slove
begin
read_Block(size); //pokus nacpat celej soubor do pameti
search:=0;
score:=0;
for data:=pos to (size-length(find)) do {!}{v pripade vetsich dat se bude mus
begin {-> prochazeni bufferem}
slovo:=0;
repeat
if find[slovo]=buffer[data+slovo] then {pozice v datech + pozice ve slove}
begin
score:=score+1;
end
» else score:=0;
inc(slovo);
until (score=0) or (data+slovo=size); {pokud nesouhlasi hledane slovo nebo
if score=length(find) then begin
search:=data;
break;
end;
score:=0;
end; {<- prochazeni bufferem }
end;
....
Watches
size = 20157
»find[slovo] = 82 'R'
data = 3
»slovo = 0
»buffer[data+slovo] = 82 'R'
score = 0
Nepomohlo ani porovnavani jako ordninalni hodnoy.
Fórum › Pascal
Spatne vyhodnocena podminka ?

Používáš dlouhý stringy? Že ti to vychází za 255 v délce hledání ve find...
V tom If Porovnáváš string find a ten začíná snad na indexu 1. K nule nemáš přistupovat, tam první znak neni snad v žádný implementaci.
Jde o to jakej používáš KOMPILER, jediný opravdu bezchybný jsou Borlandu. Zkus si změnit v nastavení kompileru OPTIMALIZACE, mě to obvykle u chybujícího a padajícího programu pomůže
to je mi taky divny ale find[1] na pozici 1 je B a hledany retezec predany funkci do FIND je RAINBOF.. Jedine ze by debuger kecal.
edit:
takze skutecne ano. bylo to tim ze jsem cetl z pozice 0, zajimave ze v prikladu
var x: string;
begin
writeln(x[0]);
end.
a pri ladeni mi to i ted ukazuje spatne udaje. rika ze find[slovo] ='A' ale pritom je to R
mi to hned vylitne na error.. neni to chyba jazyka ??? zalozim na to jine vlakno.

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
CO je spatne? — založil Figa
Co je na tomto spatne? — založil
špatné výsledky — založil vasek.t
Co mam spatne ? — založil Kamil
[DB] - špatné řazení — založil Storm
Moderátoři diskuze