Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-02

Convert C to Pascal

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hallo,

i know this is not exactly question to this maillist but maybe somebody could help me how can i convert only the following definition of "reg_drq_block_call_back" into FPC Pascal notation:

void ( * reg_drq_block_call_back ) ( struct REG_CMD_INFO * );

where definition is

struct REG_CMD_INFO
{

   unsigned char cmd;
   ... etc.

} ;

struct REG_CMD_INFO reg_cmd_info;

("struct" is simply converted to "record", that is not the problem)

Lubomir Cabla
http://www.freewebs.com/hdat2/

Reply by email

Peter Vreman
to Unknown author
Show quoted text 19 lines
Hallo, i know this is not exactly question to this maillist but maybe somebody could help me how can i convert only the following definition of "reg_drq_block_call_back" into FPC Pascal notation: void ( * reg_drq_block_call_back ) ( struct REG_CMD_INFO * ); where definition is struct REG_CMD_INFO { unsigned char cmd; ... etc. } ; struct REG_CMD_INFO reg_cmd_info; ("struct" is simply converted to "record", that is not the problem)

Pascal style:

type
  REG_CMD_INFO = record
    cmd : byte;
  end;
  reg_drq_block_call_back = procedure(var r:REG_CMD_INFO);

or more close to C style with pointers:

type
  REG_CMD_INFO = record
    cmd : byte;
  end;
  REG_CMD_INFO = ^REG_CMD_INFO;
  reg_drq_block_call_back = procedure(pr:PREG_CMD_INFO);

Reply by email

Unknown author

Thanks for your help,

1. that means this command
    reg_drq_block_call_back = 0;
    is in Pascal
    reg_drq_block_call_back := nil;

2. if ( ! reg_drq_block_call_back )
{
...
}
is in Pascal

    if reg_drq_block_call_back = nil then
    begin
       ...
    end;
3. if ( reg_drq_block_call_back )
    {
      (* reg_drq_block_call_back) ( & reg_cmd_info );
    }
    is in Pascal
    if reg_drq_block_call_back  nil then
    begin
       reg_drq_block_call_back(Addr(reg_cmd_info));
or
       reg_drq_block_call_back(@reg_cmd_info);
    end;

Is this correct ?

Lubomir Cabla

Earlier message 24 lines
-----Original Message----- From: Peter Vreman Sent: Thursday, February 19, 2004 8:41 AM To: Subject: Re: [fpc-pascal]Convert C to Pascal Pascal style: type REG_CMD_INFO = record cmd : byte; end; reg_drq_block_call_back = procedure(var r:REG_CMD_INFO); or more close to C style with pointers: type REG_CMD_INFO = record cmd : byte; end; REG_CMD_INFO = ^REG_CMD_INFO; reg_drq_block_call_back = procedure(pr:PREG_CMD_INFO);

Reply by email

Peter Vreman
to Unknown author
Show quoted text 30 lines
Thanks for your help, 1. that means this command reg_drq_block_call_back = 0; is in Pascal reg_drq_block_call_back := nil; 2. if ( ! reg_drq_block_call_back ) { ... } is in Pascal if reg_drq_block_call_back = nil then begin ... end; 3. if ( reg_drq_block_call_back ) { (* reg_drq_block_call_back) ( & reg_cmd_info ); } is in Pascal if reg_drq_block_call_back nil then begin reg_drq_block_call_back(Addr(reg_cmd_info)); or reg_drq_block_call_back(@reg_cmd_info); end; Is this correct ?

Yes

Reply by email