Functional Libraries

Hi

While searching i found the following post but it doesnt really address my query, though it is similar.

http://forums.eggplantsoftware.com/t/function-libraries/3041

I am trying to build a script library but unlike the online documentation, the “intellisense” code completion does not seem to be able to resolve my function calls to handlers even within the current suite, let alone trying to import from another suite.

I have a script called Utils that contains a handler like this:

to SomeFunction param1, param2, param3

--// do suff

end SomeFunction

I have also tried with the function keyword but the handler / function does not appear. If I create a single script per function then i can reference them fine but this is impractical from a functional grouping perspective (and very messy with many distinct files).

Can you suggest where i might be going wrong, and if there is a minimum eggplant version that this is dependent upon (we are using 18.1.2-Windows-64 2031422a).

thanks

The feature that you seek is first available in v 20.0.1. Eggplant Functional 20 Release Notes

I would recommend that you upgrade to at least 21.3.1. Eggplant Functional 21 Release Notes

You might also consider upgrading to 22.0.0. Please review the Release Notes to determine which version is right for you.

1 Like

Hi

So we have now upgraded to v22 but while functions are now resolving as handlers in the “intellisense”, the required parameters are not being broadcast. Is this something that eggplant simply does not do, or am i missing something on how to construct the function interfaces?

The following function is in a script called “TestUtils”

function test p1, p2

end test

image

image

thanks

Hi Paul.
I accomplish this through the use of SuiteSnippets. For example, here is a common function that I store in a script called HandlerGarage.


After the first time that I used it, I selected it and used the context-sensitive menu to “Create Suite Snippet.” I swapped my literals for placeholders bounded by [ ]. Here is the end product:

When I type in my script, autocomplete displays my snippet.

After selecting my snippet from the picklist, I get the code that I need along with the appropriate placeholders:

Hope this helps,
Dave

1 Like

Hi Dave

Yea, that is about the only way I can see of doing it too - I guess that is exactly the same way we have insight onto the eggplant functions, only is is less transparent on how this was achieved.

thanks

Hi again @DaveHester

Of the back of this, how does the use of multiple suites effect the ability of eggplant to resolve function names?

If you consider this structure:

  • Suite1
  •  - MainScript1
    
  • Suite2
  •   - Script2
    
  •              - Function1
    
  •              - Function2
    
  •    - Script3
    

With the following placed in MainScript1:
set the InitialSuites to ("<full_path_to_suite>\Suite2.suite")

At runtime Script3 (a standalone script) resolves and runs but functions in Script2 fail to resolve resulting in “Error: No such command:‘function1’”.

Again, is there something I’m missing?

Many thanks

When you call Function1 from Script3, are you using dot notation to indicate where SenseTalk can find that function? The call in Script3 should look like this log Script2.Function1 (parameter)
Hope this helps,
Dave

Slight amendment to the example structure, just for clarity:

  • Suite1
    • MainScript1
    • Subscript
      • Function1(p1)
  • Suite2
    • Script2
      • Function1(p1)
      • Function2(p1)
  • Script3(p1)

All calls are in the context of MainScript1.

Subscript.Function(p1) - succeeds
Script3(p1) - succeeds (calling hte entire script, NOT a function)
Script2.Function1(p1) - fails with the listed error

I have tried pulling a copy of “Script2” into “Suite1” to validate there is not an issue with reserved words; when in the local suite, the functions resolve correctly.

many thanks

Hi Paul,

I expect that you have already set it up this way, but is Suite2 set up as a helper suite to Suite1?

Hi Dave

THanks for your reply - i will verify this when i am back in the office - thank you for the pointer.

regards
paul

Hi @DaveHester

Thanks for that - I missed that finer point. Added in the reference and now works as I thought it should.

BEst regards

1 Like