Advertisement

Delphi bind to AS Error

Started by December 26, 2008 12:53 PM
1 comment, last by chronozphere 15 years, 11 months ago
I tried to implement Angelscript in Delphi. Therefore i wrote this struct-equivalent of asSMessageInfo:


type

 pasSMessageInfo = ^asSMessageInfo;
  asSMessageInfo = packed record
    sec: pchar;
    row: integer;
    col: integer;
    kind: integer;
    msg: pchar;
  end;

asEngine_SetMessageCallback(angel_engine,@AngelScriptMessageCB,nil,asCALL_CDECL); with
 
procedure AngelScriptMessageCB( const mi: pasSMessageInfo; p: pointer );cdecl;
begin
  Writeln(format('AS:%s<%s>(%d,%d)\n',[mi^.msg,mi^.sec,mi^.row,mi^.col]));
end;

but the output just shows eg AS:??????????<?????????????>(0,0) Did i do anything wrong while converting the asSMessageInfo struct?
I'm not familiar with Delphi but it looks like you've declared everything correctly.

It may be a difference in size on the pchar versus const char * types.

Does const mi: a pointer to the message information structure?

If this doesn't work, then perhaps you can write a simple wrapper callback in C++ that translates the asSMessageInfo structure to separate parameters that Delphi understands.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Set a breakpoint on that line and run it. Then check the value's of mi^.msg and mi^.sec. Also check whether "mi" points to correct data. What version of delphi do you use?

If you need further help, i'd suggest you to register at www.pascalgamedevelopment.com. You'll find more pascal/delphi programmers there that can help you out. :)

This topic is closed to new replies.

Advertisement