Advertisement

Why am I so damn stupid?

Started by October 08, 2000 04:55 PM
3 comments, last by Telamon 24 years, 3 months ago
LOL. I''ve been teaching myself VC++ by writting a lil''SpaceWar proggy. The game is pure Win32, but I built a front end to allow the players to change different options using MFC. I had assumed I would be able to figure out how to send these selections to the game as a command line. HA! All the help files I can find on "command line" concern the VC compiler command line, not building and testing programs that accept a command line. So I have two questions that maybe someone can help me with: 1. How does one pass a command line to a debug build of a program (so that I can pass a command line, then stop execution at breakpoints to make sure my code is working right). I couldn''t figure it out. 2. How does one set up a program to accept a command line? I tried running my program in the "run" selection on the Start menu like this: "d:/C++ Stuff/Spacewar.exe \1 \2 \b" and like this "d:/C++ Stuff/Spacewar.exe -1 -2 -b" but all I got was "file not found" :-( 3. Parsing a command line is hard too, isn''t it? crap. Thanks for any input ----------------------------- Let be be finale of seem, seems to me.

Shedletsky's Bits: A Blog | ROBLOX | Twitter
Time held me green and dying
Though I sang in my chains like the sea...

I don''t know about picking up command-line parameters, but to send them you need to make sure that the parameters are outside the "''s, not inside.
Thus, it should be:
"d:\C++ Stuff\Spacewar.exe" -1 -2 -b
rather than
"d:\C++ Stuff\Spacewar.exe -1 -2 -b"

-Neophyte


- Death awaits you all with nasty, big, pointy teeth. -
Advertisement
Well, I dont know why you're so stupid BUT:

int APIENTRY WinMain(HINSTANCE hInstance,                     HINSTANCE hPrevInstance,                     LPSTR     lpCmdLine,                     int       nCmdShow){   


The lpCmdLine is a pointer to a string containing all characters from the command line. This is in a standard win32 prog.

For MFC there is a member variable called m_lpCmdLine within the CWinApp class containing the same info as lpCmdLine.

As to parsing them just use a bunch of those C string manipulators or as you're using MFC those nifty CString functions.

Hope i helped...

Edited by - jumble on October 8, 2000 6:46:35 PM
jumble-----------
In MSVC 6.0 go to "Projects->Settings->Debug->Program Arguments" and type in your command line.
Great! Those three comments told me exactly what I needed to make it work. Thanks a lot! Maybe I can finish tonight...

-----------------------------
Let be be finale of seem, seems to me.

Shedletsky's Bits: A Blog | ROBLOX | Twitter
Time held me green and dying
Though I sang in my chains like the sea...

This topic is closed to new replies.

Advertisement