Autor Beitrag
majolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: Sa 08.03.03 21:47 
Hallo,

gibt es eine einfache Möglichkeit Boolean in String umzuwandeln? Ich bräuchte es,weil ich den Checked Wert einer Checkbox in einer Ini speichern möchte.
Gruss
majolo
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Sa 08.03.03 21:49 
Ganz einfach BoolToStr

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: So 09.03.03 01:39 
Hallo majolo!

Bevor du suchst, die Funktion BoolToStr gibt es nicht, zumindest bei mir in Delphi 5 nicht.
Aber die Funktion brauchst du auch nicht, denn du kannst die Prozedure TIniFile.WriteBool benutzen. Laden kannst du dann mit der Funktion ReadBool.
So, falls es dich interessiert, hier eine Funktion BoolToStr:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
function BoolToStr(const B: Boolean): String;
begin
  if B {= True} then    {True}
    Result := 'Wahr'
  else
    Result := 'Falsch'; {False}
end;
Gruß wulfskin![/b]

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 09.03.03 04:41 
Jungs, Jungs, Jungs. :shock:

Kuck euch mal die Methoden von TIniFile an. :roll:
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: So 09.03.03 10:45 
Luckie hat recht, für Ini braucht man nichts vorher konvertieren:

ausblenden Quelltext
1:
2:
3:
with TIniFile do try
  WriteBool('Sektion', 'Key', CheckBox1.Checked);
finally Free end;

_________________
Popov
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 09.03.03 10:57 
@Wulfskin:
Also bei mir gibt es die Funktion BoolToStr schon.

Zitat:
BoolToStr konvertiert einen booleschen Wert in einen String.

Unit

SysUtils

Kategorie

Typumwandlung

function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;

Beschreibung

BoolToStr konvertiert den angegebenen booleschen Wert folgendermaßen in einen String:


Zur Information:
B ist deine Booleanvariable und UseBoolStrs solltest du auf True setzen.

Beispiel:
ausblenden Quelltext
1:
aString := BoolToStr(aBoolean, True);					


Anmerkung:
Ich habe Delphi 6 Professional.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: So 09.03.03 11:17 
Die Funktion gibt es erst ab Delphi 6.

_________________
Popov
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 09.03.03 11:19 
Gut da hast du sicher recht, aber ich ging davon aus, dass es in Zeiten von Delphi 7 und kostenlosem Delphi 6 Personal kaum noch Programmierer mit Delphi 5 gibt.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: So 09.03.03 12:25 
Ich programmiere noch mit Delphi3. Warum soll ich mit Delphi6 programmieren? Ich kann doch mit Delphi 3 Professional mehr machen als mit Delphi 6 Personal. Und zu Delphi 5. In der Firma hab ich eine Enterprise Version. Die war schweineteuer und reicht aus. Soll man sich also für 4000Euro etwas kaufen nur weil es eine neue Version gibt?

_________________
Popov
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 09.03.03 12:28 
Wie gesagt ich ging davon aus, dass mindestens Delphi 6 benutzt würde. Aber du hast recht, denn ich leiste mir auch keine neue Delphi Version bei dem Preis.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
majolo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: Mo 10.03.03 19:11 
Danke nach einem Befehl wie WRITEBool habe ich gesucht, nur leider zuvor nicht gefunden.Wie man Inis schreibt und liest vom Aufruf her wusste ich, nur nicht ob es ein Aufrufmethode wie Write und ReadBool gibt.

Gruss
majolo
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Mo 10.03.03 20:48 
Wenn du nicht weiß, was für Eigenschaften ein Objekt hat, dann einfach mal, wenn du den . geschrieben hast Str+Space drücken. :)
majolo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 334

Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
BeitragVerfasst: Mo 10.03.03 21:18 
Die Eigenschaft des Objekts war mir bekannt. Ich wusste lediglich nicht ob es einen befehl gibt. Ich gebe zu,dass ich auch selber hätte draufkommen können. Als ich den Befehl ausprobiert habe ist er mir dann auch ins Auge geschimmert und habe mir gedacht,dass ich die Frage hätte sein lassen können. Aber was solls.
Linedance
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Do 03.04.03 14:54 
Titel: boolean to string
Hi, versuchs doch mal mit diesem Beispiel als einfache Umwandlung:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function booltostring(b:boolean):string;
begin
  if b then result:='1' else result:='0';
end;



procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  edit1.text:=booltostring(checkbox1.checked);
end;


Gru0, M.
Lehrling
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mi 23.04.03 13:14 
Hallo,

Oder schneller und übersichtlicher:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
function BooleanToString(Value: Boolean);
const
  BooleanStrings: array [Boolean] of string = ('Falsch', 'Wahr');
begin
  Result := BooleanStrings[Boolean];
end;



mfg Lehrling