Autor Beitrag
Bob Murphy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 91

XP, Ubuntu
Delphi 7 SE, Delphi 2007
BeitragVerfasst: Do 29.01.09 00:24 
Hi,

Ich hab ein Problem, irgend wie will die Funktion "Trim" nicht mehr so wie ich das gerne will^^
So hatte ich es eigentlich vor
ausblenden Delphi-Quelltext
1:
2:
3:
begin
  Eingabe.Text := Trim(Eingabe.Text);
end;

da das aber nicht funktioniert (keine Veränderung), habe ich schon "TrimLeft", "TrimRight" probiert, allerdings ohne Erfolg.
Ich habe es auch schon mit "AnsiLowerCase" und "AnsiUpperCase" probiert, in den Fall wird der String zwar entsprechend in groß oder klein umgewandelt, trotzdem werden keine Leerzeichen entfernt.
Ich hoffe jemand hat eine Idee:)

LG Bob


Moderiert von user profile iconNarses: Topic aus Dateizugriff verschoben am Mi 28.01.2009 um 23:28
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 29.01.09 00:38 
Was erwartest du denn von der Funktion?

Was es machen soll ist Leerzeichen und Zeilenumbrüche am Anfang und Ende des Strings zu entfernen.
Hilfe hat folgendes geschrieben:
Trim removes leading and trailing spaces and control characters from the given string S.
Bob Murphy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 91

XP, Ubuntu
Delphi 7 SE, Delphi 2007
BeitragVerfasst: Do 29.01.09 00:41 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Was erwartest du denn von der Funktion?

Was es machen soll ist Leerzeichen und Zeilenumbrüche am Anfang und Ende des Strings zu entfernen.
Hilfe hat folgendes geschrieben:
Trim removes leading and trailing spaces and control characters from the given string S.


Ich wollte halt falls am Ende der Eingabe ein Leerzeichen ist, sollte dieses entfernt werden, komischerweise wird dieses aber nicht entfernt. Was mich wundert, denn ich habe die Funktion schon öfters benutzt und die hat immer funktioniert.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 29.01.09 00:44 
Das ist dann wirklich komisch. Ich nehme ja nicht an, dass du eine andere gleichnamige Funktion deklariert hast.

Kannst du vielleicht eine Demo mit Quelltext und Exe anhängen, wo das auftritt? Und welche Delphiversion benutzt du dabei gerade?
Bob Murphy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 91

XP, Ubuntu
Delphi 7 SE, Delphi 2007
BeitragVerfasst: Do 29.01.09 00:47 
Eben... ich habe extra ein neues Projekt geöffnet, wo wirklich nur der Trim kram drinsteckt. Keine Veränderung.
Benutzen tue ich Delphi 7 SE.

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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := Trim(Edit1.Text);
end;

end.


Edit:
Hmmm ich habe das Programm mal auf mein Root hochgeladen, da funktioniert das Programm, die selbe Version funktioniert auf mein Laptop nicht. Was hilft da? An Delphi kanns ja nicht liegen, denn sonst würde es ja aufn Root auch nicht funktionieren? :shock:
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 29.01.09 00:54 
Ich habe es gerade mit Delphi 7 PE ausprobiert, das funktioniert. :nixweiss:

// EDIT:
Hmm, da fällt mir dann auch gerade nichts dazu ein.
Bob Murphy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 91

XP, Ubuntu
Delphi 7 SE, Delphi 2007
BeitragVerfasst: Do 29.01.09 01:00 
Hmm mir auch nicht, wenn jemand eine Idee hat, dann bitte posten:)
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Do 29.01.09 09:14 
Probier mal Folgendes (Ein TMemo auf die Form schmeissen);
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Var 
  i : Integer;
  s : String;
begin
  s := Eingabe.Text;
  Memo1.Lines.Add('VOR dem TRIM "'+s+'"');
  For i:= 1 to Length (s) do 
    Memo1.Lines.add(Format('%d: %.3d',[i,ord(s[i])]));

  Eingabe.Text := Trim(Eingabe.Text);
  Memo1.Lines.Add('NACH dem TRIM "'+s+'"');
  For i:= 1 to Length (s) do 
    Memo1.Lines.add(Format('%d: %.3d',[i,ord(s[i])]));
  Memo1.Lines.Add('--------------------------');
end;
Und poste das Ergebnis. NB: Der Code gibt den ASCII-Wert der Zeichen vor und nach dem TRIM aus. Dann wirst du ja sehen, ob sich was geändert hat.

_________________
Na denn, dann. Bis dann, denn.