Calling a DLL Function with Variable Parameter Lists from ATEasy

Knowledge Base Article # Q200159

Read Prior Article Read Next Article
Summary How to call a DLL function with vaiable parameters from ATEasy
  
Login to rate article
Sometimes it is desirable to create and use C/C++ functions within a DLL, that accept a variable number of parameters instead of a fixed set of parameters.

ATEasy supports use of such a function and calling it from within your test program.

The first step is to insert the appropriate DLL into your ATEasy project.

You will then need to manually define the DLL function you wish to use by inserting a new procedure in the DLL sub-module.

After inserting a new DLL procedure, select CDecl from the type drop down list of the DLL procedure properties page. CDecl is an x86 calling convention that requires the calling function to clean the stack after the called function returns, allowing a variable number of parameters to be used.
Calling a DLL Function with Variable Parameter Lists from ATEasy

Define all the fixed parameters as you would normally.
Calling a DLL Function with Variable Parameter Lists from ATEasy

When you get to the variable list, use the Any parameter type. Define as many Any parameters as you would expect to use in your variable list and mark them as optional. These optional parameters will serve as the variable list interface. Use Val Any type parameters to push parameters to the function (pass by value) or Var Any type parameters to push a pointer (pass by reference).
Calling a DLL Function with Variable Parameter Lists from ATEasy

Please refer to Tests 6.8 and 6.9 in the Language.prg example program for more information on implementation of variable parameter lists for sprintf and scanf.

Note: In order to use a variable parameter list, the DLL must be built using the CDECL convention. Please reference the Microsoft knowledge base article:
Microsoft KB Article

You must also have ATEasy 6.0 Build 136 or greater installed (Val/Var Any changes are required for this to work).
Article Date 4/28/2009
Keywords ATEasy, sprintf, scanf, variable lists


Login to rate article

1 ratings | 3 out of 5
Read Prior Article Read Next Article
>