Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Commandline-Args with Core-Console-App
Commandline-Args with Core-Console-App [message #17542] Tue, 19 August 2008 23:34 Go to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Simple Question...

How can i use commandline-args when using CONSOLE_APP_MAIN?

CONSOLE_APP_MAIN
{
	some code here... using my commandline-args...
}
Re: Commandline-Args with Core-Console-App [message #17547 is a reply to message #17542] Wed, 20 August 2008 12:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
michael wrote on Tue, 19 August 2008 17:34

Simple Question...

How can i use commandline-args when using CONSOLE_APP_MAIN?

CONSOLE_APP_MAIN
{
	some code here... using my commandline-args...
}



const Vector<String>& cl = CommandLine();

and before you ask

SetExitCode(...);

(if you do not set exit code, it is 0).

Mirek
Re: Commandline-Args with Core-Console-App [message #17552 is a reply to message #17547] Wed, 20 August 2008 13:15 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Thanks,

this works:

int argc = CommandLine().GetCount();

const Vector<String>& argv = CommandLine();
		
var1 = argv[0];
var2 = argv[1];


By the way... is there any documenation about these packages?
Re: Commandline-Args with Core-Console-App [message #17554 is a reply to message #17552] Wed, 20 August 2008 13:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
michael wrote on Wed, 20 August 2008 07:15

Thanks,

this works:

int argc = CommandLine().GetCount();

const Vector<String>& argv = CommandLine();
		
var1 = argv[0];
var2 = argv[1];


By the way... is there any documenation about these packages?


I think not yet....

Mirek
Re: Commandline-Args with Core-Console-App [message #17555 is a reply to message #17554] Wed, 20 August 2008 14:19 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Another problem:

when i try to get the first agrument like this:

int argc = CommandLine().GetCount();
const Vector<String>& argv = CommandLine();

if(argv[0]=="/?")
  {
    std::cout << "Syntax: blah blah blah" << "\n";
  }


i got an EXEPTION_ACCESS_VIOLATION reading at 0000000E.

What's wrong?



Re: Commandline-Args with Core-Console-App [message #17556 is a reply to message #17542] Wed, 20 August 2008 14:35 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
if((argc >= 1) && (argv[0]=="/?"))


BTW, try DEBUG mode sometimes, there's an ASSERT macro in Vector code, which will tell you you are trying to access member outside of current vector size.
Re: Commandline-Args with Core-Console-App [message #17562 is a reply to message #17556] Wed, 20 August 2008 20:13 Go to previous message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Thanks, this works.
Previous Topic: Smart pointer: Garbage collected by reference counting
Next Topic: Some 'missing' string functions
Goto Forum:
  


Current Time: Mon Apr 29 10:27:12 CEST 2024

Total time taken to generate the page: 0.03122 seconds