SRL Archive - Delphi/FPC Help and Tutorials

How do i make a plugin?


Infantry001

2007-04-23 16:03:49

Simple as that… how can i make a scar plugin out of Delphi? I took a look at the TestProject included in SRL, but it didnt hlep me figure out how to do it.

Please dont flame me if this is simple :P

Smartzkid

2007-04-23 16:22:57

Step 1) Go to expedia.com
Step 2) Buy one ticket
Step 3) Send the ticket to kaitnieks
Step 4) just ask him to look at your computer, and, from the same magic by which scar is derived, your plugin will appear

:D

Back ontopic…I wouldn't mind knowing how to do this, either…

Is there a way I could add, say, a menu to scar's main menu?

Does scar load plugins when it starts up?

Infantry001

2007-04-23 16:36:45

lol if i only had the money… :p

The plugins in Scar are just meant for time-critical functions, or things like that. They just create new procedures scar can use on startup.

Spky

2007-04-23 17:23:41

First make sure you have Delphi.

Second, whack open the test plugin. You will see the test functions kaitnieks put in there, delete them and make your own.

Next, find the function GetFunctionCount() and edit like so:

function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 0; //How many functions you have
end;

Then find the function GetFunctionInfo and edit:


function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall;
begin
case x of
0:
begin
ProcAddr := @SomeFunction; // Your function name here;
StrPCopy(ProcDef, 'Insert function declaration here');
end;
1:
begin
ProcAddr := @Example;
StrPCopy(ProcDef, 'function Example : Bla;');
end;
else
x := -1;
end;
Result := x;
end;

For types do the same for function GetTypeCount() but for the type info procedure have something like:


function GetTypeInfo(x: Integer; var sType, sTypeDef: string): Integer; stdcall;
begin
case x of
0:
begin
sType := 'Insert Type Here';
sTypeDef := 'Insert type definition here';
end;
1:
begin
sType := 'TNumbers';
sTypeDef := 'record n1, n2: Integer; end;';
end;
1:
begin
sType := 'TNumber';
sTypeDef := 'Integer';
end;
else
x := -1;
end;
Result := x;
end;

Now, assuming you have done everything correctly, go to (Delphi 7) Project>Compile TestPlugin. This should output a DLL named TestPlugin. To use the types/functions just restart Scar and make sure no crazy errors appear.

Wow, go freddy for adding types for plugins (or was it implemented before?).

Infantry001

2007-04-23 18:30:57

THanks, Spky! Really appreciate it!

Ruroken

2007-04-23 19:45:10

Spky to the rescue!

Glad to see your still alive :)

Freddy1990

2007-04-25 16:53:39

From: Spky
Wow, go freddy for adding types for plugins (or was it implemented before?).


If it was then I wouldn't have had to add it ;)