On 22 Feb 2011, at 21:24, Angel Montesinos wrote:

> one uncomments the commented line of code, that is  makes
>   codeFunction:= '',
> the program fails.
> 
> 
> What may be happening here?

This code is wrong:

   functionCode : AnsiString; {the function opCode sequence}
...
   Move(functionCode, PChar(FBlock^.code), len);

An ansistring is a pointer. Move takes formal const/var parameters. So the 
move() moves the pointer along with whatever data comes after it over the 
"FBlock^.code" pointer and whatever data comes after that. What you want, is to 
move the data to which functionCode points into the memory block to which 
FBlock^.code points. The correct statement is therefore:

   Move(functionCode[1], FBlock^.code^, len);

It would also be cleaner to use a dynamic array instead of a string to store 
arbitrary binary data (in that case, you'd have to use functionCode[0] above 
though).


Jonas_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to