» »

lazarus/pascal

lazarus/pascal

BRBR ::

Odrežem hash podatek na koncu csv vrstice, in ko pogledam, če je tam (tak, že odrezan), je result -1, bi moralo biti 0, menda.

Če se igram s stringi like 'krneki' potem indexof dela kot pričakovano.

Če kdo vidi v čem je fora?

var
   l : TLookupStringList;
   res: integer;
   i: integer;
begin
   l := TLookupStringList.Create;
   l.Duplicates:= dupIgnore;
   //l.LoadFromFile(ExtractFileDir(Paramstr(0)) + '\saved.txt');
   l.add ('"-1","200","0","1","cos","1","sin","0","0","1","0","1","0","0","0","0","0","0","0","|","0","100","0","1","cos","1","sin","2","0","0","1","0","1","0","0","0","0","0","0","0","|","0","50","0","1","cos","1","sin","2","0","0","1","0","1","0","0","0","0","0","0","0","|","0.5","0","359","1","0","0","bf2a51b4603448ee576b5fb627d3e2ed64e929a6"');
   for i := 0 to l.Count-1 do
   begin
      l[i] := ReplaceRegExpr(',"[a-z,0-9]{40}"',l[i],'',true);
   end;

   //get it to clp so I can copy it to next line, to be sure
   Clipboard.AsText := l[0];

   showmessage(IntToStr(l.IndexOf('"-1","200","0","1","cos","1","sin","0","0","1","0","1","0","0","0","0","0","0","0","|","0","100","0","1","cos","1","sin","2","0","0","1","0","1","0","0","0","0","0","0","0","|","0","50","0","1","cos","1","sin","2","0","0","1","0","1","0","0","0","0","0","0","0","|","0.5","0","359","1","0","0"')));
end;    

Never underestimate the power of idiots in large groups.
  • spremenil: BRBR ()

bciciban_ ::

Ne vem rešitve.

Ampak se moram javiti ko mi je tako toplo pri srcu ko vidim svojo prvo ljubezen :)

Zgodovina sprememb…

  • odbrisal: bluefish ()

BRBR ::

bciciban_ je izjavil:

Ne vem rešitve.

Ampak se moram javiti ko mi je tako toplo pri srcu ko vidim svojo prvo ljubezen :)


Tudi to je nekaj (-:
Never underestimate the power of idiots in large groups.

Zgodovina sprememb…

  • odbrisal: bluefish ()

Jure14 ::

Kolikor se spomnim pascala, grejo tam indeksi v arrayih od 1..n in ne 0..n-1
Je to mogoče težava?

bciciban_ ::

Pomoje je težava regex.
Oz. ti v produkciji že hočeš nalagat iz CSV datoteke po cele vrstice in na koncu odrezat hash ven.

Ampak kot gledam tale primer imaš ti seznam elementov, vsaka celica je svoj string, namesto en dolg string ločen z vejicami. Posledično je tale regex napačen
',"[a-z,0-9]{40}"'

napsy ::

Poskus tole:

var
   l : TLookupStringList;
   res: integer;
   i: integer;
begin
   l := TLookupStringList.Create;
   l.Duplicates:= dupIgnore;
   l.Add('"-1","200","0","1","cos","1","sin","0","0","1","0","1","0","0","0","0","0","0","0","|","0","100","0","1","cos","1","sin","2","0","0","1","0","1","0","0","0","0","0","0","0","|","0","50","0","1","cos","1","sin","2","0","0","1","0","1","0","0","0","0","0","0","0","|","0.5","0","359","1","0","0","bf2a51b4603448ee576b5fb627d3e2ed64e929a6"');
   for i := 0 to l.Count-1 do
   begin
      l[i] := ReplaceRegExpr(',"[a-z,0-9]{40}"', l[i], '', true);
   end;
   
   // Rebuild the internal hash table after modifications
   l.RebuildHash;

   Clipboard.AsText := l[0];

   ShowMessage(IntToStr(l.IndexOf('"-1","200","0","1","cos","1","sin","0","0","1","0","1","0","0","0","0","0","0","0","|","0","100","0","1","cos","1","sin","2","0","0","1","0","1","0","0","0","0","0","0","0","|","0","50","0","1","cos","1","sin","2","0","0","1","0","1","0","0","0","0","0","0","0","|","0.5","0","359","1","0","0"')));
end;
"If you die, you die. But when you live you live. There is no time to waste."

BRBR ::


l.RebuildHash;

ne obstaja.


simplified, čungalunga string zgleda nima veze:

Tule dobiš 0, pričakovano. Če pa zakomentiraš l.add ('b'); in odkomentiraš l.add ('ab'); ter odkomentiraš celoten for/next, pa dobim -1.
Checked, predzadnnja vrstica ima b, zadnja pa pravi da ga ni.


var
   l : TLookupStringList;
   res: integer;
   i: integer;
begin
   l := TLookupStringList.Create;
   l.Duplicates:= dupIgnore;

   //l.add ('ab');
   l.add ('b');

   //for i := 0 to l.Count-1 do
   //begin
   //   l[i] := ReplaceRegExpr('a',l[i],'',true);
   //end;



   //get it to clp so I can copy it to next line, to be ssure
   Clipboard.AsText := l[0];

   showmessage(IntToStr(l.IndexOf('b')));
end;                    
Never underestimate the power of idiots in large groups.

BRBR ::

Če zamenjam TLookupStringList s TStringList se vesolje vrti tako kot že vseskozi. Dela.
Kakšna misel ?

EDIT: TLookupStringList imam zato ker ni treba da je sorted, pa vseeno dela dupignore.
Never underestimate the power of idiots in large groups.

Zgodovina sprememb…

  • spremenil: BRBR ()


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

[SQL] Ali je možno postavit UNIQUE index po grupah?

Oddelek: Programiranje
211600 (1001) Spura
»

Zasuk vektorja

Oddelek: Šola
5723 (657) c0dehunter
»

Tudi mene muči en matematični problem. Prosim za pomoč.

Oddelek: Šola
51182 (1094) frudi
»

Limitiranje

Oddelek: Znanost in tehnologija
313142 (2332) CHAOS
»

freesco

Oddelek: Omrežja in internet
71813 (1639) mile

Več podobnih tem