Page 1 of 1
Command Lines
Posted: Wed Jan 02, 2002 6:22 am
by Jonozon(I forgot my pwd)
I am in the process of writing an application which plays a midi and then exits, It has no user interface or visible presence. What I need to know is this.
How can I parse command line arguments i.e.
"myapp.exe midifile.mid -repeats(5)"
I can already do the parsing of the midi filename, but I don't know how to add other arguments i.e. looping
I am writing it in Visual C++ 6, without MFC. My WinMain function looks like this:
[pre]
//--WinMain Function--//
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
s_lpCmdLine=lpCmdLine;
ifstream iMidi( s_lpCmdLine, ios::nocreate );
if ( iMidi.fail() ) {
MessageBox(NULL,"Error:File does not exist","DarkWind Midi Player",NULL);
return FALSE;
}
if(!Init(hInstance, nCmdShow)) {
MessageBox(NULL,"Failed to Initialize","Error",NULL);
CloseMusic();
return FALSE;
}
while (GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}
[/pre]
How can I parse the Commandline?
Thanks,
Jonathan
Posted: Mon Oct 01, 2007 8:01 am
by AndrewAPrice
Use std::string. Then you pass the array of command line arguments one by one through a switch statement. If "-repeats" is detected, point to the next argument, and convert that value into an int.
Posted: Mon Oct 01, 2007 8:05 am
by JamesM
If you're not using a GUI, then why are you using WinMain and Translate/DispatchMessage?
Just use "int main(char argc, char **argv)" and they're there for you, all layed out in argv
Posted: Mon Oct 01, 2007 9:43 am
by Brynet-Inc
Did both of you wake up forgetting how to interpret dates?
Why revive this ancient topic?
Posted: Mon Oct 01, 2007 10:56 am
by inflater
MessiahAndrw does like reincarnation eh?
The "dead and buried" topics that hadn't been replied *doesn't matter if revived after 5, 10, 15 or 50 years
*, could be a great opportunity for learning the things again, for those who didn't found an answer when searching the old forum section, lets say the times from MegaTokyo.
Yay, when OSdev was moving from MT, I joined in !
Regards
inflater
Posted: Mon Oct 01, 2007 11:07 am
by JAAman
...
lets say the times from MegaTokyo. Wink Yay, when OSdev was moving from MT, I joined in ! Very Happy
just one problem with your statement... OSdev didnt move from MT -- we were always here, we just agreed to take the people from the MT board when df decided to close the MT board -- iirc this board (at osdev.org) is older than the MT board
Posted: Mon Oct 01, 2007 11:41 am
by Brynet-Inc
JAAman wrote:just one problem with your statement... OSdev didnt move from MT -- we were always here, we just agreed to take the people from the MT board when df decided to close the MT board -- iirc this board (at osdev.org) is older than the MT board
That may be true... but this place wasn't even half as good until the mtDark2 theme
Posted: Mon Oct 01, 2007 4:55 pm
by JackScott
I disagree. I like this forum much more than MT, simply because it doesn't have the yucky dark theme as default!
Apparently the MT forums were added some time in 2000, and the OSdev.org ones in August of that year. Does anybody have any more idea what day they opened (specifically MT)?
Posted: Tue Oct 02, 2007 2:38 pm
by JAAman
i agree -- i really dont like the MT theme -- i read every post ever posted on both boards, but i always hated going to MT, because the color scheme there hurt my eyes and gave me a head-ache
Posted: Tue Oct 02, 2007 3:00 pm
by Brynet-Inc
JAAman wrote:i agree -- i really dont like the MT theme -- i read every post ever posted on both boards, but i always hated going to MT, because the color scheme there hurt my eyes and gave me a head-ache
Smooth dark blue gives you a headache? but bright white doesn't?
That's Insanity! mtDark2 > Default
Posted: Tue Oct 02, 2007 3:20 pm
by JAAman
no, reading text on a dark background does though...
and if i turn my brightness up really high on my monitor white can too...
the point is its too dark -- trying to make out dark text on that dark background was torture -- interestingly, its only the forums which had that horrible color combination -- the main site uses a white background, which is so much easier to read
the MT board was so bad it gave me a headache and made my eyes hurt -- i used to select the page before reading it, to invert the colors -- it did help some
Posted: Tue Oct 02, 2007 4:10 pm
by B.E
I agree with Brynet-Inc , the old MT theme was much better then the this one.