View Full Version : Plugin Help: Calling a Procedure
The_Scripts
09-17-2009, 01:13 AM
Hello,
I am currently working on a plugin that will allow a procedure to be run on a seperate thread.
The procedure in the plugin looks like this...
procedure CreateThread(ProcedureName: string); stdcall;
Is there any way for me to call apon the procedure from the plugin?
or am I wasting my time?
Quickmarch
09-17-2009, 02:22 AM
I was trying to make a thread plugin aswell, but it failed. xD Look In the "Plugins" folder of scar for TestPlugin_Globals.pas to export functions to scar.
The_Scripts
09-17-2009, 02:54 AM
At the moment I can use the procedure in SCAR.
But i'm having trouble calling a procedure that is in SCAR from the plugin.
Example.
program test;
procedure NewThreadLoop;
var
i: Integer;
begin
for i := 0 to 9 do
WriteLn(i);
end;
procedure Loop;
var
i: Integer;
begin
for i := 0 to 9 do
WriteLn(i);
end;
begin
CreateThread('NewThreadLoop'); // Call 'NewThreadLoop' on new thread.
Loop; // Should occur at, roughly, the same time as 'NewThreadLoop'.
end;
Right not I just have the CreateThread procedure in the plugin outputting "Text" to the debug box...
library The_Scripts_Plugin;
uses
FastShareMem,
SCARFunctions,
SysUtils,
Classes;
{$R *.res}
procedure CreateThread(ProcedureName: string); stdcall;
begin
WriteLn('Test');
end;
function GetFunctionCount: Integer; stdcall; export;
begin
Result := 1;
end;
function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall;
begin
case x of
0:
begin
ProcAddr := @CreateThread;
StrPCopy(ProcDef, 'procedure CreateThread(ProcedureName: string);');
end;
else
x := -1;
end;
Result := x;
end;
exports GetFunctionCount;
exports GetFunctionInfo;
begin
end.
Now I am stuck... Because I need to somehow be able to call 'NewThreadLoop' from within the plugin.
Unfortunately doing the following does not work...
procedure CreateThread(ProcedureName: string); stdcall;
begin
NewThreadLoop;
end;
I read over the file you mentioned, and I believe it just shows how I can call functions/procedure from scar. But I need to be able to call functions/procedure from SCAR in the plugin (The complete opposite).
The whole idea of this plugin is making me look something like this -> :confused:
Cazax
09-17-2009, 02:58 AM
Look at my tutorial it covers that type of questions: http://www.villavu.com/forum/showthread.php?t=41311
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.