Ask a Question

OgreODT Script Extension

tristaanogre
Community Hero

OgreODT Script Extension

OK... version 1.0 of the ScriptExtension to replace some of the functionality of deprecated ODT is available for download.  You can grab it at 

 

https://bitbucket.org/privateteamogre/scriptextensions/downloads/OgreODT.tcx

 

The initial release of this runtime object is to add ODT.Classes support for use in DelphiScript projects.  This will allow a user to Declare and create new instances of objects for use in DelphiScript code.

 

A sample code for this is below:

procedure test;
var myObject1;
var argumentArray : array[0..1];
begin
    OgreODT.Classes.Declare('test');
    OgreODT.Classes.test.AddProperty('prop1');
    OgreODT.Classes.test.AddProperty('prop2');
    OgreODT.Classes.test.AddMethod('runTest', 'Unit2.testODT');
    myObject1 := OgreODT.Classes.New('test');
    argumentArray[0] := 'test';
    argumentArray[1] := 'another test';
    aqObject.CallMethod(myObject1, 'runTest', argumentArray);
end;

This code declares a class "test" and adds two properties to it and a method.  The method calls the code at 'Unit2.testODT'.

 

There are some differences in how this works from the original ODT objects:

 

1) In DelphiScript projects, in order to call the methods of the object, you need to use aqObject.CallMethod.  I haven't figured out yet how to get this to work more natively. For other languages, calling the object method directly works just fine

2) If you need to pass parameters to your method, they need to be passed as an array and then utilized within your method as elements of that array.  This is because I haven't been able to find an easy way (yet) to make the number of parameters in the object method variable for DelphiScript utilization. 

 

The above to caveats I'll be continuing to work on in future versions.  Feel free to ask for assistance in implementation.  As always, if you use this, all I ask is attribution and that any derivatives of this contain that attribution as well.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
3 REPLIES 3
AlexKaras
Community Hero

Re: OgreODT Script Extension

Hi Robert,

 

Great work, thank you for sharing it!

 

I didn't look into the code, so asking here: given that 'test' name in your code sample is dynamic parameter, is it possible instead of

    OgreODT.Classes.Declare('test');
    OgreODT.Classes.test.AddProperty('prop1');

write this:

 

    OgreODT.Classes.Declare('test');
    OgreODT.Classes['test'].AddProperty('prop1');

?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
tristaanogre
Community Hero

Re: OgreODT Script Extension

In DelphiScript, no, that doesn't work.  You can use that notation in JScript and JavaScript however.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
AlexKaras
Community Hero

Re: OgreODT Script Extension

Thanks for the clarification, Robert.

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: