Calling a function from within another function not working in UFT
Question ID: 107801

I want to use one function library function in another function library file.

For example (leaving out actual code for brevity, I know there would be values passed, etc):

**Function LibraryA:**

Function addition()
‘do some adding
End Function

**Function LibraryB:**

Function sub()
Call addition()
End Function

Marked as spam
Posted by (Questions: 386, Answers: 64)
Asked on July 29, 2017 3:36 pm
Answers (1)
Private answer

You have to be sure to be referencing both function library files in the test. There are 4 main ways to do this.

1. Go to 'File > Settings > Resources > Associate Function Library' and associate both library files
2. Use AOM Code
3. Use ExecuteFile method somewhere in the script
4. Use LoadFunctionLibrary method somewhere in the script

(examples borrowed from (

**AOM Code:**
'Open QTP
Set objQTP = CreateObject(''QuickTest.Application'')
objQTP.Visible = True

'Open a test and associate a function library to the test
objQTP.Open ''C:AutomationSampleTest'', False, False
Set objLib = objQTP.Test.Settings.Resources.Libraries

'If the library is not already associated with the test case, associate it..
If objLib.Find(''C:SampleFunctionLibrary.vbs'') = -1 Then ' If library is not already added
objLib.Add ''C:SampleFunctionLibrary.vbs'', 1 ' Associate the library to the test case

**ExecuteFile method:**

ExecuteFile ''C:YourFunctionLibrary.vbs''

**LoadFunctionLibrary method:**

LoadFunctionLibrary ''C:YourFunctionLibrary_1.vbs'' 'Associate a single function library
LoadFunctionLibrary ''C:FuncLib_1.vbs'', ''C:FuncLib_2.vbs'' 'Associate more than 1

Marked as spam
Posted by (Questions: 16, Answers: 807)
Answered on July 29, 2017 3:42 pm
Oh I wasn't referencing one of the libraries. Thanks, this is helpful!!
( at July 29, 2017 3:43 pm)

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

Scroll to Top