Forum Discussion

Trikkels's avatar
Trikkels
New Contributor
4 years ago

Pass Uniface-application object between units

Hi, I have a working (windows application) uniface-test, and now trying to divide this up into re-usable parts (units). So 1 of the first things I need to do is open the application and pass it on from one unit to another. When I run tis I get the following message: "Unable to find the object MDIClient. See Details for additional information"

 

Anyone an idea what is going wrong here?

 

Here are my 3 units:

Unit 1 = start unit:

var unitTZISAPP = require("TZISAPP");

var unitTZISAPP_LOGON = require("TZISAPP_LOGON"); 

function CallTestObjects(){

let TZisApp = unitTZISAPP.letZisApp();

let returnvalue = unitTZISAPP_LOGON.TZisAppLogOn(TZisApp);

Log.Message(returnvalue);}

 

Unit 2 called TZISAPP:

module.exports.letZisApp = letTZISAPP; 

function letTZISAPP(){

//Start application

return TestedApps.Tzis.Run();}

 

Unit 3 called TZISAPP_LOGON:

module.exports.TZisAppLogOn = TZISAPPLogOn; 

function TZISAPPLogOn(TZisApp){

let wndUniMDIFormLogOn = TZisApp.MDIClient.wndUniMDIForm;   => ERROR ON THIS LINE

let uViewPortLogOn = wndUniMDIFormLogOn.uviewport;

let uniCanvasLogOn = uViewPortLogOn.UniCanvas;

let editLogOnUserName = uniCanvasLogOn.Edit;

editLogOnUserName.Drag(46, 8, -86, -1);

editLogOnUserName.SetText("x047593");

let editLogOnPassword = uniCanvasLogOn.Edit2;

editLogOnPassword.Click(30, 11);

editLogOnPassword.SetText(Project.Variables.Password1);

let btnOKLogOn = uniCanvasLogOn.OwiCmdButton.btnOk;

btnOKLogOn.ClickButton();

return 1;}

 

 

2 Replies

  • what are you supplying as the argument for the function in your unit3 (so what are you passing for the parameter TZisApp)

    function TZISAPPLogOn(TZisApp){
    
    let wndUniMDIFormLogOn = TZisApp.MDIClient.wndUniMDIForm;
    •  if TZisApp is the name of your testedapplication, why do you need the argument within your function?
    • the Variable of TZisApp that you set in the other units dont seem to be global (so they are within the scope of the separate units only; i dont know enough about the syntax of the language you are using to give you suggestions on how to do this, but a google search should yield results here "how to make global variable in x language")
  • Trikkels's avatar
    Trikkels
    New Contributor

    Hi hkim, thanks for your reply. Mayby I can put the app as global, but I wanted to pass all objects I use through parameters.