LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Does CVI support command line argc & argv as standard C?

I try to run my CVI.exe from command line (msdos) but failed to display what I type in:
 
- cd\CVI_applications (where my test.exe located)
 
- test trial <Enter>
 
And here my codes:
 
int main (int argc, char *argv[])
{
 int i=0;
 char *str_c;
  
 Fmt(str_c, "%s<%i", argc);
 
 InsertTextBoxLine (panelHandle, PANEL_TEXTBOX, i++, str_c);
 InsertTextBoxLine (panelHandle, PANEL_TEXTBOX, i++, argv[1]);
 
 return 1;
}
 
But It shows nothing, I thought it should show 2 (2 entries) then trial (string of 2nd parameter)
 
Thanks for any help
0 Kudos
Message 1 of 7
(5,062 Views)

Hi,

Thats is correct about the arguments.

If this is the complete exe code, then its no surprise you are not seeing the values.

You need to add the code to load the UIR to obtain the value of panelHandle.

You need to display the panel.

You need to call RunUserInterface(), or at least put in some code so that the program stops for a while.

Trying running your code in CVI and set abreakpoint at the beginning, then you can check the values for argc and argv.

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 2 of 7
(5,061 Views)
Howdy plit string,

Ray was correct in the sense that your not displaying any user interfaces but yet you are referencing handles to panels and control IDs. If you are just trying to see if you are receiving the correct arguments, I would just use printf or DebugPrintf statements. 

Check out the KnowledgeBase Passing a Command Line Argument To a Stand-Alone Executable Created in LabWindows/CVI for some help.

It talks about the Run >> Command Line option in LabWindows/CVI. This feature allows you to
enter the command line arguments for your program. When you run your program in the LabWindows/CVI environment, LabWindows/CVI passes the command line arguments to your main function in the argc and argv parameters.

Hope this helps!

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 3 of 7
(5,038 Views)

Thank Jonathan, it works perfectly form msdos. If you do not mind  can I ask you one more deep detail:

Can I do the same execution, but not in msdos environment? Let say I want to call cpass.exe from CVI (ie: similar LaunchExecutable ("")) but with the arguments (cpass Hello World) ... is there a way to do it?

Many thanks

0 Kudos
Message 4 of 7
(5,031 Views)
I got it, thanks for the explaination Smiley Happy
0 Kudos
Message 5 of 7
(5,027 Views)
Hi plit string,

Select Run >> Command Line and type Hello World into the field. Then when you execute your program from CVI, it will pass these parameters to your main function.

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 6 of 7
(5,028 Views)

Hi Jonathan,

The way you show me that run directly from msdos (cmd), but what I need is used from CVI program.

Anyway, I did search through help file an dfinally found the command system (...) and it works perfectly

Thank for trying helps Smiley Wink

0 Kudos
Message 7 of 7
(4,990 Views)