Sign in Join

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

Mailing lists / fpc-pascal / 2003-07

XChat plugins using FPC

23 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

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

James Mills

Hi,

I can successully compile and test the plugin source listed at http://xchat.org/docs/plugin20.html written in C.

However I don't like C much and am wondering if it's possible to do the same thing in pascal... ? I know it has to be possible, but I need someone to start me off in the right direction...

cheers
James

- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Marco van de Voort
to James Mills
Show quoted text 6 lines
I can successully compile and test the plugin source listed at http://xchat.org/docs/plugin20.html written in C. However I don't like C much and am wondering if it's possible to do the same thing in pascal... ? I know it has to be possible, but I need someone to start me off in the right direction...

Probably yes, but you'll need to convert headers of xchat-plugin.h. The "h2pas" util can be handy for this. (or at least it can save a lot of time)

Reply by email

L D Blake
to Marco van de Voort

Ok, 3 checkboxes defined on a small window on win2000...

    s := 'Start processing when loaded';
    OToy[1] := createwindow('Button',Cstr(S,cpt),ws_tabstop or
                  ws_child or ws_visible or bs_autocheckbox,
                  10,15,185,20,Ohandle,1,mdrProg,nil);
    s := 'Exit when done';
    OToy[2] := createwindow('Button',Cstr(S,cpt),ws_tabstop or
                  ws_child or ws_visible or bs_autocheckbox,
                  10,35,180,20,Ohandle,2,mdrProg,nil);
    s := 'Make noise when done';
    OToy[3] := createwindow('Button',Cstr(S,cpt),ws_tabstop or
                  ws_child or ws_visible or bs_autocheckbox,
                  10,55,180,20,Ohandle,3,mdrProg,nil);

Cstr is a pascal to c string converter routine that takes a normal pascal string (S in this case) and hands the winAPI a pointer to a null terminated buffer (cpt)... tested and working elsewhere as well so that's not the problem.

The little app is up and going, error free, but for the life or me I can't get the ws_tabstop function to work... When the app loads nobody has focus and I can hit the tab key all day and nothing happens...

Why can't I tab between these controls?

-----
L D Blake

Reply by email

James Mills
to Marco van de Voort: Probably yes, but you'll need to convert headers of xchat-plugin.h. The "h2pas" util can…
Marco van de Voort wrote 9 lines
> I can successully compile and test the plugin source listed at > http://xchat.org/docs/plugin20.html written in C. > > However I don't like C much and am wondering if it's possible to do the > same thing in pascal... ? I know it has to be possible, but I need > someone to start me off in the right direction... Probably yes, but you'll need to convert headers of xchat-plugin.h. The "h2pas" util can be handy for this. (or at least it can save a lot of time)

Now once these headers are converted...

When writing the plugin source itself, do I need to use PChar's instead of pascal strings ?

cheers
James

Show quoted text 5 lines
_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

James Mills
to Marco van de Voort: Probably yes, but you'll need to convert headers of xchat-plugin.h. The "h2pas" util can…
Marco van de Voort wrote 9 lines
> I can successully compile and test the plugin source listed at > http://xchat.org/docs/plugin20.html written in C. > > However I don't like C much and am wondering if it's possible to do the > same thing in pascal... ? I know it has to be possible, but I need > someone to start me off in the right direction... Probably yes, but you'll need to convert headers of xchat-plugin.h. The "h2pas" util can be handy for this. (or at least it can save a lot of time)

Okay I've converted the headers (step 1) :P

$ h2pas -S -D -p -l xchat xchat-plugin.h
at line 6 error : syntax error
Illegal character in line 6
"#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \" at line 7 error : syntax error
Illegal character in line 7
" (XCHAT_IFACE_MINOR * 100) + \"

What do I do with these errors though ?

cheers
James

Show quoted text 5 lines
_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 24 lines
On Wed, Jul 23, 2003 at 03:28:55AM +0200, Marco van de Voort wrote: > > I can successully compile and test the plugin source listed at > > http://xchat.org/docs/plugin20.html written in C. > > > > However I don't like C much and am wondering if it's possible to do the > > same thing in pascal... ? I know it has to be possible, but I need > > someone to start me off in the right direction... > > Probably yes, but you'll need to convert headers of xchat-plugin.h. The > "h2pas" util can be handy for this. (or at least it can save a lot of time) Okay I've converted the headers (step 1) :P $ h2pas -S -D -p -l xchat xchat-plugin.h at line 6 error : syntax error Illegal character in line 6 "#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \" at line 7 error : syntax error Illegal character in line 7 " (XCHAT_IFACE_MINOR * 100) + \" What do I do with these errors though ?

run the file through the gcc preprocessor:

gcc -E xchat-plugin.h -o xchat-plugin.hp
h2pas -S -D -p -l xchat xchat-plugin.hp

Note that this destroys all '#define' constants, so you'll have to run h2pas a second time to get all constants.

Michael.

Reply by email

Michael Van Canneyt
to James Mills: Now once these headers are converted... When writing the plugin source itself, do I need…
James Mills wrote 15 lines
On Wed, Jul 23, 2003 at 03:28:55AM +0200, Marco van de Voort wrote: > > I can successully compile and test the plugin source listed at > > http://xchat.org/docs/plugin20.html written in C. > > > > However I don't like C much and am wondering if it's possible to do the > > same thing in pascal... ? I know it has to be possible, but I need > > someone to start me off in the right direction... > > Probably yes, but you'll need to convert headers of xchat-plugin.h. The > "h2pas" util can be handy for this. (or at least it can save a lot of time) Now once these headers are converted... When writing the plugin source itself, do I need to use PChar's instead of pascal strings ?

Your entry and exit points need that, yes. But all in between can be done using strings.

Michael.

Reply by email

James Mills
to Michael Van Canneyt
Michael Van Canneyt wrote 22 lines
On Wed, 23 Jul 2003, James Mills wrote: > On Wed, Jul 23, 2003 at 03:28:55AM +0200, Marco van de Voort wrote: > > > I can successully compile and test the plugin source listed at > > > http://xchat.org/docs/plugin20.html written in C. > > > > > > However I don't like C much and am wondering if it's possible to do the > > > same thing in pascal... ? I know it has to be possible, but I need > > > someone to start me off in the right direction... > > > > Probably yes, but you'll need to convert headers of xchat-plugin.h. The > > "h2pas" util can be handy for this. (or at least it can save a lot of time) > > Now once these headers are converted... > > When writing the plugin source itself, do I need to use PChar's instead > of pascal strings ? Your entry and exit points need that, yes. But all in between can be done using strings.

Kewl thanks :)

James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

James Mills
to Michael Van Canneyt: run the file through the gcc preprocessor: gcc -E xchat-plugin.h -o xchat-plugin.hp h2pas…
Michael Van Canneyt wrote 36 lines
On Wed, 23 Jul 2003, James Mills wrote: > On Wed, Jul 23, 2003 at 03:28:55AM +0200, Marco van de Voort wrote: > > > I can successully compile and test the plugin source listed at > > > http://xchat.org/docs/plugin20.html written in C. > > > > > > However I don't like C much and am wondering if it's possible to do the > > > same thing in pascal... ? I know it has to be possible, but I need > > > someone to start me off in the right direction... > > > > Probably yes, but you'll need to convert headers of xchat-plugin.h. The > > "h2pas" util can be handy for this. (or at least it can save a lot of time) > > Okay I've converted the headers (step 1) :P > > $ h2pas -S -D -p -l xchat xchat-plugin.h > at line 6 error : syntax error > Illegal character in line 6 > "#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \" > at line 7 error : syntax error > Illegal character in line 7 > " (XCHAT_IFACE_MINOR * 100) + \" > > > > What do I do with these errors though ? run the file through the gcc preprocessor: gcc -E xchat-plugin.h -o xchat-plugin.hp h2pas -S -D -p -l xchat xchat-plugin.hp Note that this destroys all '#define' constants, so you'll have to run h2pas a second time to get all constants.

Okay, I'll try that :)

I tried fixing the header file, but obviously you know what to do better than i :P

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Matt Emson
to L D Blake: Ok, 3 checkboxes defined on a small window on win2000... s := 'Start processing when…

The answer is simple, but very illusive!!!

while (GetMessage(wmsg, FWindowHandle, 0, 0)) do begin
    if not ( IsDialogMessage(FWindowHandle, wmsg) ) then  ///this is the
line you nees to add
      TranslateMessage(wmsg);
    DispatchMessage(wmsg);
  end;

If you look at what TranslateMessage actually does it all becomes clear.

Matt

Earlier message 46 lines
----- Original Message ----- From: "L D Blake" To: Sent: Wednesday, July 23, 2003 3:17 AM Subject: [fpc-pascal]Ummmm... anyone know why this doesn't work... > Ok, 3 checkboxes defined on a small window on win2000... > > > s := 'Start processing when loaded'; > OToy[1] := createwindow('Button',Cstr(S,cpt),ws_tabstop or > ws_child or ws_visible or bs_autocheckbox, > 10,15,185,20,Ohandle,1,mdrProg,nil); > s := 'Exit when done'; > OToy[2] := createwindow('Button',Cstr(S,cpt),ws_tabstop or > ws_child or ws_visible or bs_autocheckbox, > 10,35,180,20,Ohandle,2,mdrProg,nil); > s := 'Make noise when done'; > OToy[3] := createwindow('Button',Cstr(S,cpt),ws_tabstop or > ws_child or ws_visible or bs_autocheckbox, > 10,55,180,20,Ohandle,3,mdrProg,nil); > > > Cstr is a pascal to c string converter routine that takes a normal pascal > string (S in this case) and hands the winAPI a pointer to a null terminated > buffer (cpt)... tested and working elsewhere as well so that's not the > problem. > > The little app is up and going, error free, but for the life or me I can't get > the ws_tabstop function to work... When the app loads nobody has focus and I > can hit the tab key all day and nothing happens... > > Why can't I tab between these controls? > > ----- > L D Blake > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Reply by email

Ingmar Tulva
to L D Blake: Ok, 3 checkboxes defined on a small window on win2000... s := 'Start processing when…

Tabbing through controls is handled in DefDialogProc() when 1) dialog is modal or 2) you call IsDialogMessage() explicitly. I have no idea how to implement this when the buttons are inserted into a window of another class (when DefDialogProc is not the window procedure); certainly it is possible somehow. An option is to trap keypress messages and do the tabbing yourself.

hope this helps,
Ingmar

On Tue, 22 Jul 2003, L D Blake wrote:

}Ok, 3 checkboxes defined on a small window on win2000... }
}
} s := 'Start processing when loaded';
} OToy[1] := createwindow('Button',Cstr(S,cpt),ws_tabstop or } ws_child or ws_visible or bs_autocheckbox, } 10,15,185,20,Ohandle,1,mdrProg,nil); } s := 'Exit when done';
} OToy[2] := createwindow('Button',Cstr(S,cpt),ws_tabstop or } ws_child or ws_visible or bs_autocheckbox, } 10,35,180,20,Ohandle,2,mdrProg,nil); } s := 'Make noise when done';
} OToy[3] := createwindow('Button',Cstr(S,cpt),ws_tabstop or } ws_child or ws_visible or bs_autocheckbox, } 10,55,180,20,Ohandle,3,mdrProg,nil); }
}
}Cstr is a pascal to c string converter routine that takes a normal pascal }string (S in this case) and hands the winAPI a pointer to a null terminated }buffer (cpt)... tested and working elsewhere as well so that's not the }problem.
}
}The little app is up and going, error free, but for the life or me I can't get }the ws_tabstop function to work... When the app loads nobody has focus and I }can hit the tab key all day and nothing happens... }
}Why can't I tab between these controls?
}
}-----
} L D Blake
}
}
}_______________________________________________
}fpc-pascal maillist -
}http://lists.freepascal.org/mailman/listinfo/fpc-pascal }

------

Ingmar

------

"I occasionally make the mistake of having social contact with other human beings."

Reply by email

Matt Emson
to Ingmar Tulva
Show quoted text 6 lines
Tabbing through controls is handled in DefDialogProc() when 1) dialog is modal or 2) you call IsDialogMessage() explicitly. I have no idea how to implement this when the buttons are inserted into a window of another class (when DefDialogProc is not the window procedure); certainly it is possible somehow. An option is to trap keypress messages and do the tabbing yourself.

Actually, it's 'TranslateMessage' that is causing the problem. From the WinSDK helpfile:
"The TranslateMessage function translates virtual-key messages into character messages. The character messages are posted to the calling thread's message queue, to be read the next time the thread calls the GetMessage or PeekMessage function."

It is therefore removing the VK_TAB from the message the Button etc sends. This is needed to implement the WS_TABSTOP functionality.

I've tested this in a framework I have been tinkering with (multithreaded widget framework, each window has it's own thread, as does the application instance) and it solved the lack of tabstop immediately.

If you're interested I can send you the source to look at, though it's in a bit of a strange state at the moment die to me hacking it to solve the above probelm (without initially knowing how to.)

Matt

Reply by email

L D Blake
to Matt Emson: The answer is simple, but very illusive!!! while (GetMessage(wmsg, FWindowHandle, 0, 0))…

In reply to your message of July 23, 2003

Show quoted text 10 lines
The answer is simple, but very illusive!!! while (GetMessage(wmsg, FWindowHandle, 0, 0)) do begin if not ( IsDialogMessage(FWindowHandle, wmsg) ) then ///this is the line you nees to add TranslateMessage(wmsg); DispatchMessage(wmsg); end; If you look at what TranslateMessage actually does it all becomes clear.

THANKS! ... I never would have stumbled on that one without some help.

The final version is this:

    while GetMessage(@oMsg,0, 0, 0) do
      begin
        if not (IsDialogMessage(OHandle,omsg)) then
          begin
            TranslateMessage(oMsg);
            DispatchMessage(oMsg);
          end;
      end;

I had to bracket both translatemessage and dispatchmessage before it would work.

Now the ws_group and ws_defpushbutton work too.

-----
L D Blake

Reply by email

Matt Emson
to L D Blake
Show quoted text 16 lines
In reply to your message of July 23, 2003 > The answer is simple, but very illusive!!! > while (GetMessage(wmsg, FWindowHandle, 0, 0)) do begin > if not ( IsDialogMessage(FWindowHandle, wmsg) ) then ///this is the > line you nees to add > TranslateMessage(wmsg); > DispatchMessage(wmsg); > end; > If you look at what TranslateMessage actually does it all becomes clear. THANKS! ... I never would have stumbled on that one without some help.

Cool. I'll amend my code too. It semed to work fine with the DispatchMessage still available, but I'm using multiple threads and a hack to get the compiler to treat methods as callback procs, so that could be the reason.

It was a pleasure because it stumped me too, to begin with ;-)

Matt

Reply by email

James Mills
to Michael Van Canneyt: run the file through the gcc preprocessor: gcc -E xchat-plugin.h -o xchat-plugin.hp h2pas…
Michael Van Canneyt wrote 43 lines
On Wed, 23 Jul 2003, James Mills wrote: > On Wed, Jul 23, 2003 at 03:28:55AM +0200, Marco van de Voort wrote: > > > I can successully compile and test the plugin source listed at > > > http://xchat.org/docs/plugin20.html written in C. > > > > > > However I don't like C much and am wondering if it's possible to do the > > > same thing in pascal... ? I know it has to be possible, but I need > > > someone to start me off in the right direction... > > > > Probably yes, but you'll need to convert headers of xchat-plugin.h. The > > "h2pas" util can be handy for this. (or at least it can save a lot of time) > > Okay I've converted the headers (step 1) :P > > $ h2pas -S -D -p -l xchat xchat-plugin.h > at line 6 error : syntax error > Illegal character in line 6 > "#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \" > at line 7 error : syntax error > Illegal character in line 7 > " (XCHAT_IFACE_MINOR * 100) + \" > > > > What do I do with these errors though ? run the file through the gcc preprocessor: gcc -E xchat-plugin.h -o xchat-plugin.hp h2pas -S -D -p -l xchat xchat-plugin.hp Note that this destroys all '#define' constants, so you'll have to run h2pas a second time to get all constants. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

I've sucessfully now done all this and now have the headers converted... I have a problem though when trying to compiling a test plugin:

$ fpc test
Free Pascal Compiler version 1.0.6 [2002/08/10] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling test.pas
Compiling xchatplugin.pas
xchatplugin.pas(49,24) Error: Identifier not found XCHAT_PLUGIN
xchatplugin.pas(49,36) Error: Error in type definition
xchatplugin.pas(50,22) Error: Identifier not found XCHAT_LIST
xchatplugin.pas(50,32) Error: Error in type definition
xchatplugin.pas(51,22) Error: Identifier not found XCHAT_HOOK
xchatplugin.pas(51,32) Error: Error in type definition
xchatplugin.pas(55,25) Error: Identifier not found XCHAT_CONTEXT
xchatplugin.pas(55,38) Error: Error in type definition
xchatplugin.pas(61,24) Error: Duplicate identifier _XCHAT_PLUGIN
xchatplugin.pas(61,24) Error: Duplicate identifier _XCHAT_PLUGIN
xchatplugin.pas(62,60) Error: Identifier not found PXCHAT_PLUGIN
xchatplugin.pas(62,96) Error: Type identifier expected
xchatplugin.pas(62,96) Fatal: Syntax error, ) expected but FUNCTION found

What's going on here ?

cheers
James

- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Marco van de Voort
to James Mills
I've sucessfully now done all this and now have the headers converted... I have a problem though when trying to compiling a test plugin:

Hard to say without source. Please post the sources (headers, demo program, and maybe some readme that explains some stuff like needed xchat library version etc) somewhere.

Reply by email

Michael Van Canneyt
to James Mills: I've sucessfully now done all this and now have the headers converted... I have a problem…
James Mills wrote 70 lines
On Wed, Jul 23, 2003 at 08:50:35AM +0200, Michael Van Canneyt wrote: > > > On Wed, 23 Jul 2003, James Mills wrote: > > > On Wed, Jul 23, 2003 at 03:28:55AM +0200, Marco van de Voort wrote: > > > > I can successully compile and test the plugin source listed at > > > > http://xchat.org/docs/plugin20.html written in C. > > > > > > > > However I don't like C much and am wondering if it's possible to do the > > > > same thing in pascal... ? I know it has to be possible, but I need > > > > someone to start me off in the right direction... > > > > > > Probably yes, but you'll need to convert headers of xchat-plugin.h. The > > > "h2pas" util can be handy for this. (or at least it can save a lot of time) > > > > Okay I've converted the headers (step 1) :P > > > > $ h2pas -S -D -p -l xchat xchat-plugin.h > > at line 6 error : syntax error > > Illegal character in line 6 > > "#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \" > > at line 7 error : syntax error > > Illegal character in line 7 > > " (XCHAT_IFACE_MINOR * 100) + \" > > > > > > > > What do I do with these errors though ? > > run the file through the gcc preprocessor: > > gcc -E xchat-plugin.h -o xchat-plugin.hp > h2pas -S -D -p -l xchat xchat-plugin.hp > > Note that this destroys all '#define' constants, so you'll have to > run h2pas a second time to get all constants. > > Michael. > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal I've sucessfully now done all this and now have the headers converted... I have a problem though when trying to compiling a test plugin: $ fpc test Free Pascal Compiler version 1.0.6 [2002/08/10] for i386 Copyright (c) 1993-2002 by Florian Klaempfl Target OS: Linux for i386 Compiling test.pas Compiling xchatplugin.pas xchatplugin.pas(49,24) Error: Identifier not found XCHAT_PLUGIN xchatplugin.pas(49,36) Error: Error in type definition xchatplugin.pas(50,22) Error: Identifier not found XCHAT_LIST xchatplugin.pas(50,32) Error: Error in type definition xchatplugin.pas(51,22) Error: Identifier not found XCHAT_HOOK xchatplugin.pas(51,32) Error: Error in type definition xchatplugin.pas(55,25) Error: Identifier not found XCHAT_CONTEXT xchatplugin.pas(55,38) Error: Error in type definition xchatplugin.pas(61,24) Error: Duplicate identifier _XCHAT_PLUGIN xchatplugin.pas(61,24) Error: Duplicate identifier _XCHAT_PLUGIN xchatplugin.pas(62,60) Error: Identifier not found PXCHAT_PLUGIN xchatplugin.pas(62,96) Error: Type identifier expected xchatplugin.pas(62,96) Fatal: Syntax error, ) expected but FUNCTION found What's going on here ?

The unit is not correct. There are things that h2pas doesn't 'know' about. C is case sensitive. Pascal is not. so duplicate identifiers can exist. the C construct "xchat_plugin *" is translated to 'Pxchat_plugin', but that may or may not be defined already.

In general, a generated file may still need some manual editing before it is compilable. This is perfectly normal.

Michael.

Reply by email

Holger Peters
to James Mills: I can successully compile and test the plugin source listed at…

Hi,

if you are successful, I would be glad to receive the ported Header files and a small example.

Holger

Show quoted text 13 lines
Hi, I can successully compile and test the plugin source listed at http://xchat.org/docs/plugin20.html written in C. However I don't like C much and am wondering if it's possible to do the same thing in pascal... ? I know it has to be possible, but I need someone to start me off in the right direction... cheers James

Reply by email

James Mills
to Holger Peters
Holger Peters wrote
Hi, if you are successful, I would be glad to receive the ported Header files and a small example.

rofl! :) Make me do all the hard work :(
This is the first time I've converted any c headers of any sort... I'm getting close though

I think I'll end up writing a unit interface to the c functions though. I don't want to end up writing plugins and having to remember every bloody xchat interface command :) do you ?

cheers
James

Show quoted text 24 lines
Holger James Mills schrieb: >Hi, > >I can successully compile and test the plugin source listed at >http://xchat.org/docs/plugin20.html written in C. > >However I don't like C much and am wondering if it's possible to do the >same thing in pascal... ? I know it has to be possible, but I need >someone to start me off in the right direction... > >cheers >James > > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

James Mills
to Michael Van Canneyt: The unit is not correct. There are things that h2pas doesn't 'know' about. C is case…
Michael Van Canneyt wrote 82 lines
On Thu, 24 Jul 2003, James Mills wrote: > On Wed, Jul 23, 2003 at 08:50:35AM +0200, Michael Van Canneyt wrote: > > > > > > On Wed, 23 Jul 2003, James Mills wrote: > > > > > On Wed, Jul 23, 2003 at 03:28:55AM +0200, Marco van de Voort wrote: > > > > > I can successully compile and test the plugin source listed at > > > > > http://xchat.org/docs/plugin20.html written in C. > > > > > > > > > > However I don't like C much and am wondering if it's possible to do the > > > > > same thing in pascal... ? I know it has to be possible, but I need > > > > > someone to start me off in the right direction... > > > > > > > > Probably yes, but you'll need to convert headers of xchat-plugin.h. The > > > > "h2pas" util can be handy for this. (or at least it can save a lot of time) > > > > > > Okay I've converted the headers (step 1) :P > > > > > > $ h2pas -S -D -p -l xchat xchat-plugin.h > > > at line 6 error : syntax error > > > Illegal character in line 6 > > > "#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \" > > > at line 7 error : syntax error > > > Illegal character in line 7 > > > " (XCHAT_IFACE_MINOR * 100) + \" > > > > > > > > > > > > What do I do with these errors though ? > > > > run the file through the gcc preprocessor: > > > > gcc -E xchat-plugin.h -o xchat-plugin.hp > > h2pas -S -D -p -l xchat xchat-plugin.hp > > > > Note that this destroys all '#define' constants, so you'll have to > > run h2pas a second time to get all constants. > > > > Michael. > > > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > I've sucessfully now done all this and now have the headers converted... > I have a problem though when trying to compiling a test plugin: > > $ fpc test > Free Pascal Compiler version 1.0.6 [2002/08/10] for i386 > Copyright (c) 1993-2002 by Florian Klaempfl > Target OS: Linux for i386 > Compiling test.pas > Compiling xchatplugin.pas > xchatplugin.pas(49,24) Error: Identifier not found XCHAT_PLUGIN > xchatplugin.pas(49,36) Error: Error in type definition > xchatplugin.pas(50,22) Error: Identifier not found XCHAT_LIST > xchatplugin.pas(50,32) Error: Error in type definition > xchatplugin.pas(51,22) Error: Identifier not found XCHAT_HOOK > xchatplugin.pas(51,32) Error: Error in type definition > xchatplugin.pas(55,25) Error: Identifier not found XCHAT_CONTEXT > xchatplugin.pas(55,38) Error: Error in type definition > xchatplugin.pas(61,24) Error: Duplicate identifier _XCHAT_PLUGIN > xchatplugin.pas(61,24) Error: Duplicate identifier _XCHAT_PLUGIN > xchatplugin.pas(62,60) Error: Identifier not found PXCHAT_PLUGIN > xchatplugin.pas(62,96) Error: Type identifier expected > xchatplugin.pas(62,96) Fatal: Syntax error, ) expected but FUNCTION found > > > What's going on here ? The unit is not correct. There are things that h2pas doesn't 'know' about. C is case sensitive. Pascal is not. so duplicate identifiers can exist. the C construct "xchat_plugin *" is translated to 'Pxchat_plugin', but that may or may not be defined already. In general, a generated file may still need some manual editing before it is compilable. This is perfectly normal.

I'm a little confused as to what manual editing is necessary... What about the:

  const
    External_library='xchat'; {Setup as you need}

What does this need to be ?

Does the unit need to be linked with anything ? (There are no xchat libraries I am aware of).

Help me out here :P (please)

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

L D Blake
to L D Blake: In reply to your message of July 23, 2003 THANKS! ... I never would have stumbled on that…

A little while back Matt Emson helped me with the message dispatcher for windows programs... we arrived at something like this:

Show quoted text 8 lines
while GetMessage(@oMsg,0, 0, 0) do begin if not (IsDialogMessage(OHandle,omsg)) then begin TranslateMessage(oMsg); DispatchMessage(oMsg); end; end;

I've kept tinkering with it in a multi window program where each window has it's own WinProc to handle buttons, clicks and things. Rather than use multiple dispatchers (which seems not to improve performance much) I kept tinkering with the one above and arrived at:

  // Message dispatcher for all windows
  while GetMessage(WMsg,0,0,0) do
    begin
      if not IsDialogMessage(getforegroundwindow,wmsg) then
        begin
          TranslateMessage(WMsg);
          DispatchMessage(WMsg);
        end;
    end;

I currently have 6 windows that pop up at various times and this handles tabbing and menu selection for them all, quite nicely.

So Matt... if you're reading this you might like to try it out.

-----
L D Blake

Reply by email

Ingmar Tulva
to L D Blake

On Tue, 5 Aug 2003, L D Blake wrote:

} // Message dispatcher for all windows
} while GetMessage(WMsg,0,0,0) do
} begin
} if not IsDialogMessage(getforegroundwindow,wmsg) then } begin
} TranslateMessage(WMsg);
} DispatchMessage(WMsg);
} end;
} end;
}
}I currently have 6 windows that pop up at various times and this handles }tabbing and menu selection for them all, quite nicely. }
}So Matt... if you're reading this you might like to try it out.

Nice and simple. Don't know about Matt but thanks from here; I have bounced into this problem now and then and used all kinds of ugly solutions :-)

Ingmar

Reply by email

L D Blake
to Ingmar Tulva

In reply to your message of August 5, 2003

Nice and simple.

<Grin> I like "nice and simple"....

Don't know about Matt but thanks from here; I have bounced into this problem now and then and used all kinds of ugly solutions :-)

My pleasure.

-----
L D Blake

Reply by email