domik
15 years agoOccasional Contributor
How to write Classes/DataObjects generator using Script Extensions
I didn't found any information that would help me do something like this.
I would like
to develop by myself or maybe use any existing extension that would be a
wizard for creating an ODT.Classes
I have code like above and what I would like to do is to create a wizard that would generate code like above right to Script Unit.
The steps I'm thinking of are:
TestedObjectParentPath - FullName of the object parent.
TestedObjectPath - FullName of the tested object.
Because I doesn't see any way to store object inside Class or Data Object I want to evaluate this strings to have an object on which I will be executing methods. So question is - is there any easy way to change something like this:
Sys.Process('Application').VCLObject('MainForm')
to correct string object which in delphiscript would look like this one
'Sys.Process(''''Application'''').VCLObject(''''MainForm'''') '
FindValue - if something would go wrong while evaluating object I can try to find it using parent.FindChildren() - currently I'm using ObjectIdentifier proprerty
ObjClassName - ObjectType property
Does any one have done something similar ? Any tips to creating such code by wizard ?
function CreateClassObject;
var Obj;
begin
// Declares new classes
ODT.Data.Clear;
ODT.Classes.Clear;
ODT.Classes.Declare('BaseObject');
Obj := ODT.Classes.TcObject;
// Adds two properties to the class
Obj.AddProperty('TestedObjectParentPath', 0);
Obj.AddProperty('FindProperty', 'ObjectIdentifier');
Obj.AddProperty('FindValue', '');
Obj.AddProperty('TestedObjectPath', 0);
Obj.AddProperty('ObjClassName', 0);
Obj.AddProperty('Value', '');
Obj.AddMethod('FindObject','Classes.FindObject');
Obj.AddMethod('GetObjClassName','Classes.GetObjClassName');
Obj.AddMethod('DefaultOperation','Classes.DefaultOperation');
end;
function CreateClassLogin;
var LoginObj, ClassInstance, PropNum;
begin
DeleteGroupByName('Login');
DeleteClassByName('Login');
// Declares new classes
ODT.Classes.Declare('Login');
LoginObj := ODT.Classes.Login;
LoginObj.AddPropOfClassType('_wndfrmLogin', 'BaseObject');
LoginObj.AddPropOfClassType('_edttLogin', 'BaseObject');
LoginObj.AddPropOfClassType('_edtPassword', 'BaseObject');
LoginObj.AddPropOfClassType('_btnLogin', 'BaseObject');
end;
function CreateObjectLogin;
var Group, VarClass;
begin
DeleteGroupByName('Login');
// Creates a new data group
Group := ODT.Data.AddGroup('Login');
// Adds new variables to the created data group
VarClass := Group.AddVarOfClassType('LoginTest', 'Login');
end;
procedure FillOdtLoginProperties();
var LoginTestObj;
begin
LoginTestObj:= ODT.Data.Login.LoginTest;
LoginTestObj._wndfrmLogin.TestedObjectParentPath:=ODT.Data.Enviroment.Enviroment._CurrentTestedApplication;
LoginTestObj._wndfrmLogin.FindValue:='wndfrmLogin';
LoginTestObj._edttLogin.TestedObjectParentPath:= LoginTestObj._wndfrmLogin.TestedObjectParentPath;
LoginTestObj._edttLogin.FindValue:='edtUserName';
//LoginTestObj._edtLogin. TestedObjectPath := '';
LoginTestObj._edtLogin.Methods['DefaultOperationMethod'].Enabled := true;
LoginTestObj._edtPassword.TestedObjectParentPath :=LoginTestObj._wndfrmLogin.TestedObjectParentPath;;
LoginTestObj._edtPassword.FindValue:='edtPassword';
//LoginTestObj.edtPassword.TestedObjectPath :='';
LoginTestObj.edtPassword.Methods['DefaultOperationMethod'].Enabled := true;
LoginTestObj._btnLogin.TestedObjectParentPath :=LoginTestObj._wndfrmLogin.TestedObjectParentPath;;
LoginTestObj._btnLogin.FindValue:='btnLogin';
//LoginTestObj.btnLogin.TestedObjectPath:='';
LoginTestObj._btnLogin.Methods['DefaultOperationMethod'].Enabled := true;
end;
procedure FillOdtLoginValues();
var LoginTestObj;
begin
LoginTestObj:= ODT.Data.Login.LoginTest;
LoginTestObj._edtLogin.Value:='login';
LoginTestObj._edtPassword.Value:='password';
end;
procedure OdtLoginTestRun();
begin
ODT.Data.Login.Run;
end;
I would like
to develop by myself or maybe use any existing extension that would be a
wizard for creating an ODT.Classes
I have code like above and what I would like to do is to create a wizard that would generate code like above right to Script Unit.
The steps I'm thinking of are:
- Form for editing values like ClassName, application that this Class applies to (combobox)
- Next form would let me point an object in application which will be added to class. I would give this object name according to what this object do in application.
- I would like to take properties of this object and put into Class that I'm just creating.
- Messagebox that would ask "Do you want to add next property of class ?"
- Some empty methods for whole class like DefaultMethod or something
TestedObjectParentPath - FullName of the object parent.
TestedObjectPath - FullName of the tested object.
Because I doesn't see any way to store object inside Class or Data Object I want to evaluate this strings to have an object on which I will be executing methods. So question is - is there any easy way to change something like this:
Sys.Process('Application').VCLObject('MainForm')
to correct string object which in delphiscript would look like this one
'Sys.Process(''''Application'''').VCLObject(''''MainForm'''') '
FindValue - if something would go wrong while evaluating object I can try to find it using parent.FindChildren() - currently I'm using ObjectIdentifier proprerty
ObjClassName - ObjectType property
Does any one have done something similar ? Any tips to creating such code by wizard ?
function CreateClassObject;
var Obj;
begin
// Declares new classes
ODT.Data.Clear;
ODT.Classes.Clear;
ODT.Classes.Declare('BaseObject');
Obj := ODT.Classes.TcObject;
// Adds two properties to the class
Obj.AddProperty('TestedObjectParentPath', 0);
Obj.AddProperty('FindProperty', 'ObjectIdentifier');
Obj.AddProperty('FindValue', '');
Obj.AddProperty('TestedObjectPath', 0);
Obj.AddProperty('ObjClassName', 0);
Obj.AddProperty('Value', '');
Obj.AddMethod('FindObject','Classes.FindObject');
Obj.AddMethod('GetObjClassName','Classes.GetObjClassName');
Obj.AddMethod('DefaultOperation','Classes.DefaultOperation');
end;
function CreateClassLogin;
var LoginObj, ClassInstance, PropNum;
begin
DeleteGroupByName('Login');
DeleteClassByName('Login');
// Declares new classes
ODT.Classes.Declare('Login');
LoginObj := ODT.Classes.Login;
LoginObj.AddPropOfClassType('_wndfrmLogin', 'BaseObject');
LoginObj.AddPropOfClassType('_edttLogin', 'BaseObject');
LoginObj.AddPropOfClassType('_edtPassword', 'BaseObject');
LoginObj.AddPropOfClassType('_btnLogin', 'BaseObject');
end;
function CreateObjectLogin;
var Group, VarClass;
begin
DeleteGroupByName('Login');
// Creates a new data group
Group := ODT.Data.AddGroup('Login');
// Adds new variables to the created data group
VarClass := Group.AddVarOfClassType('LoginTest', 'Login');
end;
procedure FillOdtLoginProperties();
var LoginTestObj;
begin
LoginTestObj:= ODT.Data.Login.LoginTest;
LoginTestObj._wndfrmLogin.TestedObjectParentPath:=ODT.Data.Enviroment.Enviroment._CurrentTestedApplication;
LoginTestObj._wndfrmLogin.FindValue:='wndfrmLogin';
LoginTestObj._edttLogin.TestedObjectParentPath:= LoginTestObj._wndfrmLogin.TestedObjectParentPath;
LoginTestObj._edttLogin.FindValue:='edtUserName';
//LoginTestObj._edtLogin. TestedObjectPath := '';
LoginTestObj._edtLogin.Methods['DefaultOperationMethod'].Enabled := true;
LoginTestObj._edtPassword.TestedObjectParentPath :=LoginTestObj._wndfrmLogin.TestedObjectParentPath;;
LoginTestObj._edtPassword.FindValue:='edtPassword';
//LoginTestObj.edtPassword.TestedObjectPath :='';
LoginTestObj.edtPassword.Methods['DefaultOperationMethod'].Enabled := true;
LoginTestObj._btnLogin.TestedObjectParentPath :=LoginTestObj._wndfrmLogin.TestedObjectParentPath;;
LoginTestObj._btnLogin.FindValue:='btnLogin';
//LoginTestObj.btnLogin.TestedObjectPath:='';
LoginTestObj._btnLogin.Methods['DefaultOperationMethod'].Enabled := true;
end;
procedure FillOdtLoginValues();
var LoginTestObj;
begin
LoginTestObj:= ODT.Data.Login.LoginTest;
LoginTestObj._edtLogin.Value:='login';
LoginTestObj._edtPassword.Value:='password';
end;
procedure OdtLoginTestRun();
begin
ODT.Data.Login.Run;
end;