Hallo Steve
SB> The following code works when I compile with Delphi 1.x but not
SB> with Delphi 2. Anyone know why?
SB> begin
SB> CharByte:=FBuffer[x];
SB> If (CharByte0) or (CharByte32) then
SB> begin
SB> CharByte:=CharByte xor Ord(Key[Ctr]);
SB> FBuffer[x]:=CharByte;
SB> end;
SB> If (CharByte=0) or (CharByte=32) then
SB> CharByte:=CharByte xor Ord(Key[Ctr]);
SB> If Ctr>KeyLen then Ctr:=0;
SB> Application.ProcessMessages;
SB> end;
Hard to tell without seeing the whole picture. Key and FBuffer could be
strings, fixed length strings or array's of characters. Either way I think it
should work though, but these types and the way to manipulate them can differ
depending on environment settings and I would suspect them first.
Other matters of interest could be:
- How is KeyLen determined? Key[0] would _not_ return a
meaningful value in Delphi 2 if Key were a string.
All that put aside, the code doesn't seem to make a lot of sence. The first
condition will always be true (CharByte will always be not equal to null or
not equal to space). You propably meant AND in stead of OR. If so, the code
could be leaner since the XOR operation is performed anyway, no matter you're
dealing with space or nulls or not. You could put the XOR operation over the
if-then construct. One if-then for changing the buffer would suffice,
followed by an else clause instead of a new if-then. In this particular piece
of code CharByte does not seem to be used at all after it is assigned to in
case of a null or a space so you may drop that part all toghether. Be careful
though, I cannot see what happens further on. The ProcessMessages statement
however suggests this piece of code is called repeatedly in a tight loop,
encrypting one character at a time of a possibly very large file. There would
be no point in encrypting a space or null without using the result.
Groeten, Martin.
--- FMail/386 1.02
---------------
* Origin: -=[ E-mail: m_maat@knoware.nl .......... ]=- (2:286/420.1)
|