SRL Archive - Extensions

Launching java from an extension


Iamadam

2011-03-02 21:16:12

Heya.

I want to launch a java application from an extension in Simba.
Simba doesn't include the CMD library (has the exec procedure), so I made a dll with the function I need.

The dll works fine in a normal script, but the second I try to load it in an extension, it won't compile.


Any ideas?

Here's extension code:
program Zazu;
{$LOADLIB executor.dll}
function openZazu : boolean;
begin
writeln('Trying to execute...');
Execute('java', pluginPath + '\zazu.jar');
end;
procedure onClick(Sender: TObject);
begin
if (not (fileExists(includePath + 'SRL\SRL\core\SPS\worldmap.bmp'))) then
begin
writeln('World map not found. Is SPS installed??');
Exit;
end;
WriteLn('Opening Zazu...');
if(openZazu) then
writeln('Zazu opened')
else
writeln('Zazu couldn''t be opened');
end;


procedure init;
var
simbaMenu : TMenuItem;
begin
simbaMenu := TMenuItem.create(Simba_MainMenu);
simbaMenu.caption := 'Run Zazu';
simbaMenu.onClick := @onClick;
simba_MainMenu.items.items[4].insert(Simba_MainMenu.Items.Items[4].count, SimbaMenu);
end;

function getName: string;
begin
Result := 'Zazu Launcher';
end;

function getVersion: string;
begin
Result := '1.0';
end;
Obviously it's not quite finished, but yeah - why won't it load the library?

Wizzup?

2011-03-03 03:49:43

I'm unsure if the extensions have support for importing plugin functions. That may be the reason. What is the error from the extension? My guess it that it doesn't know ``Execute''?

Iamadam

2011-03-03 07:17:01

No, has no problem with execute.
Error in Simba extension (C:\Simba\Extensions\Zazu.sex) : Unknown compiler directives at 2:3
Extension Disabled - Did not compile

Wizzup?

2011-03-03 17:31:15

From: Iamadam
No, has no problem with execute.
Error in Simba extension (C:\Simba\Extensions\Zazu.sex) : Unknown compiler directives at 2:3
Extension Disabled - Did not compile


Yeah; same thing. The LOADLIB directive isn't enabled for extensions.

Iamadam

2011-03-04 05:00:25

I tried loading the proc using:

procedure execute(path, cmdLine : String);
external 'execute@executor.dll stdcall';

That gave no errors, but it still failed to compile.
Argh.
Please include the cmd or process unit in the next version of Simba!
:)

Quickmarch

2011-03-04 07:16:04

From: Iamadam

Please include the cmd or process unit in the next version of Simba!
:)


I support this!

e: this or {$loadlib ..} directive…

noidea

2011-03-04 07:26:50

I suggested adding exec() and the like while Simba was still young.. People didn't like it because they thought it would more easily allow people to make malicious scripts. This is true, but its not the language's/simba's fault if malicious scripts are made with it….

Bobzilla69

2011-03-04 07:37:18

i dont know if its possible, but why not make simba have to enter a "special" mode to use these functions? kinda like windows UAC asking if your sure.

Iamadam

2011-03-04 17:27:50

Yeah it could run malicious scripts, sure. But any plugin could contain malicious code too :S
Yup, no problem with it asking if you trust the source before using exec the first time. (just as long as you can do 'trust always').

Wizzup?

2011-03-08 11:09:07

From: noidea
I suggested adding exec() and the like while Simba was still young.. People didn't like it because they thought it would more easily allow people to make malicious scripts. This is true, but its not the language's/simba's fault if malicious scripts are made with it….


Simba is still young… ;-)

From: Iamadam
Yeah it could run malicious scripts, sure. But any plugin could contain malicious code too :S
Yup, no problem with it asking if you trust the source before using exec the first time. (just as long as you can do 'trust always').


Well, if you really want to use this I suggest you file a bug, perhaps someone will add it in the near future. Either exec or loading plugins in extensions. Latter seems more useful to me.