Using Scripts within a Script

     

1.  You can create your own library of common Functions and Procedures and hold them independently within - or outside of – Ostendo, then call these from within your Main Script. The advantage of using this feature is that you do not need to key in full script details every time you create a Script but can simply quote the name of the 'Sub' script

 

To set this up in the main script you are required to add two lines

 

Uses

'FunctionsLibrary';

 

Where Uses tells Ostendo that you are using

'FunctionsLibrary' is the name of the 'Sub' Script that you are calling

 

The first line ('Uses') MUST be the first line in the Main Script.  The next line is the script name.  The following example has a script called 'MainScript' within which the sub script 'FunctionsLibrary' will be called

 

 

Firstly create the Main script called (say) 'MainScript' with the following

 

uses 'FunctionsLibrary';

var

TheCustomer,ThePhoneNumber: string;

begin

TheCustomer := AskQuestionWithLookup('Customer', '',1015);

{This calls a simple procedure within the FunctionsLibrary to display the Customer name passed}

DisplayCustomer(TheCustomer);

{This calls a simple function within the FunctionsLibrary and returns the phone number for the Customer passed}

ThePhoneNumber := ReturnPhoneNumber(TheCustomer);

showmessage('The phone number for ' + TheCustomer + ' is ' + ThePhoneNumber + '');

end.

 

Next create a Script called (say) 'FunctionsLibrary' with the following

 

procedure DisplayCustomer(PassedCustomerName:string);

begin

showmessage(PassedCustomerName);

end;

 

function ReturnPhoneNumber(PassedCustomerName:string):string;

begin

result := GetSQLResult('select CUSTOMERPHONE from CustomerMaster where Customer = ''' + PassedCustomerName + '''');

end;

 

begin

end.

 

If you now run 'MainScript' you be asked to select a Customer from the Customer Master file.  This is stored in Variable 'TheCustomer'. 

 

Procedure 'DisplayCustomer' is now called from ''FunctionsLibrary' and the variable 'TheCustomer' passed to it.  This procedure will then display the passed Customer Name.

 

Function 'ReturnPhoneNumber' is now called from ''FunctionsLibrary' and the Customer's phone number is extracted from the CustomerMaster record of the passed Customer.  This is then displayed in a Showmessage.

 

 

2. Other Options

 

2.1. Storing the 'called' Script

 

You have three options where to store the 'called' script and this reflected in the opening line of the main Script.  I.e. If you specify :

 

uses 'FunctionsLibrary'

Ostendo will look for the 'FunctionsLibrary' script in Ostendo's Table CUSTOMSCRIPTS

 

uses 'FunctionsLibrary.txt'

Ostendo will look for file 'FunctionsLibrary.txt' which should be in a folder (which you have previously created) called 'Functions' located directly under the Ostendo folder (example C:\Program Files\Ostendo\Functions\FunctionsLibrary.txt)

 

uses 'D:\Dev-X\Scripts\FunctionsLibrary.txt'

Ostendo will look for file 'FunctionsLibrary.txt' at the location you state

 

 

2.2. Encrypted Scripts

 

You can use either encrypted or un-encrypted scripts


NB: Once a script is encrypted, it cannot be de-crypted later