Innerfuse Pascal Script
Back to Index.
Q: How do I install Innerfuse Pascal Script in the Delphi IDE?
A: You can't. It's not a component, but a library. See the next FAQ item for help on how to get started.
Q: How to get started?
A: Download the library, unzip it and make sure ifspas.pas, ifs_utl.pas, ifs_var.pas, ifs_obj.pas are in your library path, and ifs_def.inc in your include path.
Add ifspas, ifs_var and ifs_utl to your uses.
Add this code:
var
ScriptEngine: TIfPasScript;
begin
ScriptEngine := TIfPasScript.Create(nil);
ScriptEngine.SetText(ScriptData); // replace scriptdata with where the script is (for example: memo1.text)
ScriptEngine.RunScript;
if Scriptengine.ErrorCode <> ENoError then
ShowMessage('Error: '+ErrorToString(ScriptEngine.Error, ScriptEngine.ErrorString));
ScriptEngine.Free;
end;
Q: Why doesn't the uses work how it should work.
A: When calling OnUses the ScriptEngine.OnUses is called. SYSTEM uses is always called, even with no OnUses. You can add variables, types, classes or functions there or your could attach a script to it.
Q: How can I add a variable to the variable list:
A: The prefered way to do it is in the OnUses function:
function MyOnUses(id: Pointer; Sender: TIfPasScript; Name: string): TIfPasScriptError
begin
if Name='SYSTEM' then begin
Sender.AddVariable('Edit1Text', 'String', False)^.CV_Str := Edit1.Text;
RegisterStdLib(Sender); // This function adds the standard libraries.
MyOnUses := ENoError;
end else
MyOnUses := EUnknownIdentifier;
end;
After the TIfPasScript.Create, you put: script.OnUses := MyOnUses;
Q: How can I read the value of a variable:
A: First call GetVariable('VarName'), if the result of that function is nil, the variable does not exist. Else if it does exist, the function returns returns an PIFVariant.
Q: Can you help me with ....? Are you going to add .....?
A: I prefer you post questions, bug reports or suggestions on our newsserver:
news://www.carlo-kok.com
if the news server does not work, please report it to me.
Copyright (c) 2001 by Carlo Kok
last update: 24-11-01