royd
7 years agoRegular Contributor
Global variable troubles (Calling Variables Declared in Another Unit) in javascript
I have successfully used "//USEUNIT" method of calling functions and variables in the past. I am trying to use "module.exports" method and can not figure out how to make it work. Here is what I have -
The source unit:
//Patinet_Information var nameOfPatient; function patientStat(){ ... nameOfPatient = page.FindChild("idStr", "patientName", 10).contentText; ... } module.exports.nameOfPatient;
The destination unit:
var patientInfo = require("Patinet_Information"); function createPatient(){ ... let pName = page.FindChildByXPath("//input[@id='userName']");; pName.SetText(nameOfPatient); }
I have also tried
pName.SetText(patientInfo.nameOfPatient);
did not work ("nameOfPatient is undefined").
Thanks in advance for any help.
Dave