Syntax

code

Function: ExecuteScript(ParamList: String = ''): Variant;


Description

Executes the script property, passing a CRLF delimited list of parameters. Returns the value assigned to Result in the script.


Code Reference


code

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

procedure psExecuteScript;

var

  ps: IPlanSwift;

  itm: IItem;

  prop: IPropertyObject;

  formula: string;

begin

  //Create The Planswift Interface

  ps := coPlanswift.Create;

  //Get the Selected Item

  itm := ps.SelectedItem;

  //Check if var is empty

  if varisclear(itm) then begin

    showmessage('Please Select an Item');

    ps := nil;

    Exit;

  end;

  //write The Script to execute

  formula :=  'ShowMessage(' + chr(39) + 'Script has been Executed' + chr(39) + ');';

  //Create a New Property and set its type to script

  prop := itm.NewProperty('Custom Script',formula,ptscript);

  //Set the Script type to method

  prop.ScriptType := stMethod;

  //Set the language to pascal

  prop.ScriptLanguage := slPascal;

  //Execute the Script

  prop.ExecuteScript('');

  //Free Planswift interface

  ps := nil;

end;