LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert string to ViChar array?

Hello,

i created a wrapper for a ivi function and added to addtional parameters to it (Result and TXT).

It is working fine but how can i make the bold text working?

The "if" part works only problem in the else-path.

How can i set the string into the ViChar array?

 

Thanks for help

 

 

        void __declspec(dllexport) ConfigureOutputEnabled(ViSession vi,  ViInt32 index, ViBoolean enabled, ViInt32 &Result, ViChar TXT[] )
        {

             ....

            Result = IviDCPwr_ConfigureOutputEnabled(vi, channelName, enabled);
            if (Result != 0)
            {
                IviDCPwr_error_message(vi, Result, TXT);
            }
            else
            {
                //TXT[] = "No error"; //How to change this?
            }
        }
0 Kudos
Message 1 of 3
(3,689 Views)

If you want your dll to return the result value to the caller you should declare it as ViInt32 *Result, and use *Result in the function body.

For the string parameter, couldn't you declare it as a ViChar * and fill it with strcpy ()? I'm not using Ivi so I don't know if this is safe for IviDCPwr_error_message () function.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(3,678 Views)

There is no problem with Result parameter.

 

strcpy is not working here.

I solved it with this:

Copying index by index into the output array.

 

              ViChar temp[] = "No error.";
               for(int i = 0; i < sizeof(temp); ++i)
                       TXT[i] = temp[i];

 

0 Kudos
Message 3 of 3
(3,675 Views)