Calling a Function

Hi guys,

I have this function:

ExecuteScriptFunction(const CString strFunc,  const CStringArray& paramArray)


How would I call it?


String value, Array
String value, lots of string values


?


Cheers!
LVL 4
Cyber-DrugsAsked:
Who is Participating?
 
AxterConnect With a Mentor Commented:
Hi Cyber-Drugs,
> How would I call it?

You need a CStringArray object to call this function.

Example:
CStringArray MyStrArray;
//Then populate above array

//Then call the function
ExecuteScriptFunction("foofoo", MyStrArray);



David Maisonave (Axter)
Cheers!
0
 
Cyber-DrugsAuthor Commented:
Sorry Axter,

I suppose what I meant was...

How do I populate a CStringArray?


Cheers!
0
 
mahesh1402Commented:
why not to use VARIABLE ARGUMENT FUNCTION with which you can pass unlimited no. (varaible) of arguments to function....just like printf().. as you know you may pass any no. of arguments to printf().. you may also have such type of function...

so that in function itself you may pass any no. strings  as parameters like :
ExecuteScriptFunction(const CString strFunc, strArg1,strArg2,strArg3......)

Look here for how to declare and define them :
http://www.codeproject.com/cpp/argfunctions.asp
http://www.codeguru.com/cpp/cpp/cpp_mfc/functions/article.php/c4025/

-MAHESH
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
mahesh1402Commented:
more simple example related to variable argument is here :
http://www.codeproject.com/cpp/C___Variable_Arguments.asp

-MAHESH
0
 
Cyber-DrugsAuthor Commented:
Hi Mahesh,

Thank you for all the detailed links, and I will be reading them to learn a few new tricks, but for this question I'm basically looking for something I can cut and paste into C++ to test if the function works properly...

As you helped write the function, maybe you could show me how to use it?

Cheers!
0
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
CStringArray ar;

ar.Add("string1");
ar.Add("string2");
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.