Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 06.12.06 14:03 
Hi, Delpher,

(wie) kann ich eine Zeichenkette vom Typ widestring untersuchen?

Der Compiler meckert, wenn ich den widestring auf das Vorkommen von einem Punkt an der dritte oder sechsten Stelle untersuche (ist wegkommentiert), also wenn es ein Datum ist. Es gibt aber auch so noch einen Sortierfehler.

Code:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
procedure TForm1.SortTnTStringGrid(var GenStrGrid: TTntStringGrid; ThatCol: Integer);
const Separator = '@';  // Trennzeichen
var CountItem, I, J, K, S_Position, spos2 : integer;
    MyString, TempString                  : widestring;  // array[1..25] of WideChar?
    pufstr1, pufstr2, mykurzstr           : widestring;  // mit UNICODE-Unterst³tzung!
    flag                                  : boolean;
begin
  CountItem := GenStrGrid.RowCount;
  TntListbox1.Sorted := False;
  try
    begin
      flag := false;
      for I := 1 to (CountItem - 1) do  // i := 1 => also mit _berschrift/Tabellenkopf
      begin
        if (length(GenStrGrid.Rows[I].Strings[ThatCol]) > 1) and
           (GenStrGrid.Rows[I].Strings[ThatCol][3] = '.')   and
           (GenStrGrid.Rows[I].Strings[ThatCol][6] = '.')   then
        begin
          flag := true; pufstr1 := '';
          pufstr1 := pufstr1 + GenStrGrid.Rows[I].Strings[ThatCol][ 4]+
                               GenStrGrid.Rows[I].Strings[ThatCol][ 5]+
                               GenStrGrid.Rows[I].Strings[ThatCol][ 1]+
                               GenStrGrid.Rows[I].Strings[ThatCol][ 2]+
                               GenStrGrid.Rows[I].Strings[ThatCol][ 7]+
                               GenStrGrid.Rows[I].Strings[ThatCol][ 8]+
                               GenStrGrid.Rows[I].Strings[ThatCol][ 9]+
                               GenStrGrid.Rows[I].Strings[ThatCol][10]+
                               GenStrGrid.Rows[I].Strings[ThatCol][ 3]+
                               GenStrGrid.Rows[I].Strings[ThatCol][ 6];
          GenStrGrid.Rows[I].Strings[ThatCol] := pufstr1;
        end;
        TntListbox1.Items.Add(GenStrGrid.Rows[I].Strings[ThatCol] + Separator +
                              GenStrGrid.Rows[I].Text);
      end;

      TntListbox1.Sorted := true;

      for K := 1 to TntListbox1.Count do
      begin
        MyString := TntListbox1.Items.Strings[(K - 1)];

{        if flag then
        begin
          mykurzstr := mystring[1]+ mystring[2]+ mystring[3]+ mystring[4]+
                       mystring[5]+ mystring[6]+ mystring[7]+ mystring[8]+
                       mystring[9]+ mystring[10];
          pufstr2 := '';
          pufstr2 := pufstr2 + mystring[3]+ mystring[4]+ mystring[9]+
                               mystring[1]+ mystring[2]+ mystring[10]+
                     mystring[5]+ mystring[6]+ mystring[7]+ mystring[8];
          Delete(mystring, 1,10); insert(pufstr2, mystring, 1);
        end; }


        S_Position := Pos(Separator, MyString);
        TempString  := '';
        TempString := Copy(MyString, (S_Position + 1), Length(MyString));

        if flag then
        begin
          SPos2 := Pos(mykurzstr, tempString);
          Delete(tempstring, SPos2, 10); insert(pufstr2, tempstring, SPos2);
        end;

        TntListbox1.Items.Strings[(K - 1)] := '';
        TntListbox1.Items.Strings[(K - 1)] := TempString;

      end;

      for J := 1 to (CountItem - 1) do    // zur³ck ins StringGrid
      begin
        GenStrGrid.Rows[J].Text := TntListbox1.Items.Strings[(J - 1)];
      end;
    end;
  finally
    TntListbox1.Free;
  end;
end;


Wer kann helfen? Vielen Dank, Detlef
Grenzgaenger
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 06.12.06 22:35 
@d. annies... tja, bei mir meckert der compiler nicht...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 s: widestring = 'hulahop';
begin
  s := copy(s,1,pos('a',s)-1) + 'y' + copy(s, pos('a',s)+1,length(s));
  if length(s)>0 then s := s + s[1];
  delete(s,length(s) div 2, 1);
  writeln(s);
  readln;
end.