AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

boolarrtostr ???

Ein Thema von braingrenade · begonnen am 9. Okt 2003 · letzter Beitrag vom 10. Okt 2003
 
Benutzerbild von braingrenade
braingrenade

Registriert seit: 30. Okt 2002
Ort: Neufra
274 Beiträge
 
Delphi 6 Personal
 
#1

boolarrtostr ???

  Alt 9. Okt 2003, 15:47
Moin leute !!

Ich möchte gerne ein boolarr
type Tboolarr = array of Boolean ; in einen string umwandeln also zb. 00101010100111111000001010100101 in 'xyz' .
ich hab mir auch schon ne function geschrieben , welche aber als result immer '' ausgiebt .
Delphi-Quellcode:
function bintobyte(const AsValue : string) : byte;
//Danke an Daniel B für diese Funktion !!!!
const
  _aBinDigits = ['0','1'];

var
  iPowerOfTwo : integer;
  i : integer;

begin
  Result := 0;
  iPowerOfTwo := 1;
  if (length(AsValue) < 1) or (length(AsValue) > 8) then
  begin
    raise Exception.Create('Die Zahl muss zwischen 1 und 8 Stellen haben.');
  end;
  for i := length(AsValue) downto 1 do
  begin
    if not (AsValue[i] in _aBinDigits) then
    begin
      raise Exception.Create('Es dürfen nur die Ziffern 0 und 1 vorkommen.');
    end;
    if AsValue[i] = '1then
    begin
      Result := Result or iPowerOfTwo;
    end;
    iPowerOfTwo := iPowerOfTwo shl 1;
  end;
end;

//in diser Funktion liegt der Fehler
function Tbitcrypt.boolarrtostr(ba : Tboolarr): string;
var i,i2 : integer;
    buf,b : string;
begin
result := '';
for i := 0 to high(ba) do
begin
 if ba[i] = true then buf := buf +'1'
 else buf := buf + '0';
end;

i:=1;
i2:=0;
repeat
 if i2 = 8 then
  begin
   i2 :=0;
   result := result+ char(bintobyte(b));
   b := '';
  end;
 b := b+buf[i];
 i2 := i2 +1;
 i:=i+1;
until i = length(buf)+2;
end;
Weiß jemand woran das liegen könnte ?
Let the sun beat down upon my face
Stars fill my dream
I am a traveller of both time and space
To be where I have been ________________ Such A Surge
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz