PDA

View Full Version : Dos programming Concept problem.



L.O.K.
12-13-2002, 06:17 AM
I was usually programming in windows before.

now i recognized a difference between win and dos programming:

in win, like VB , FLASH, etc. it can run muti - program at a time,
like playing the music, playing movie , and calculation at the same time.

dos program , usually it has only one "main loop" ,
the program is running the "loop" continuously .

what is the way to run muti - program?

Waldo2k2
12-13-2002, 10:39 AM
you obviously don't understand windows programming very well either. Windows programming has one main loop controlling everything just as a DOS app does. The main difference is that a windows program works with windows to accomplish tasks, a dos app does everything on it's own.

there is no way to multi-task in dos if that's what you're asking.

L.O.K.
12-13-2002, 11:22 AM
Originally posted by Waldo2k2
you obviously don't understand windows programming very well either. Windows programming has one main loop controlling everything just as a DOS app does. The main difference is that a windows program works with windows to accomplish tasks, a dos app does everything on it's own.

there is no way to multi-task in dos if that's what you're asking.

>>>you obviously don't understand windows programming very well .

yes, since i only write VB and FLASH before.


Like VB or VC++ , it has "timer",
we can run many timers at the same time.
i know that every program is a MAIN LOOP looping.

is it means that i must write progman like this :

// a muti - timer's progman
void main(){
if ( time to invoke the timer function ) ......;
if ( time to invoke the timer function ) ......;
if ( time to invoke the timer function ) ......;
..
..
..
}

is it like this ?


and if the "PLAYMUSIC()" function in a game is running,
but how can control the sprite ??

that means that i must write :

int i
void main(){
playmusic( the i'th note );
control (....);
....
....
i++;
}

like this form????

Waldo2k2
12-13-2002, 11:30 AM
what you're asking about has nothing to do with windows or dos programming, it's simply a matter of it being in c/c++.
You can write a program with several if statements or anything else you want, just as in windows. Here's an example program in DOS.


#include <iostream>
using namespace std;
//NEVER USE VOID MAIN, EVER!!
int main()
{
for (int i=0;i<=5;i++)
{
std::cout<<"hello"<<std::endl;
}
return 0;
}

Magos
12-13-2002, 12:43 PM
Things aren't running at the same time in Windows either. Put a while(true){} somewhere in your code and you'll see that your program halts.

There is a concept know as multithreading, but it doesn't make things run simultaneously. It's just an illusion. Windows runs a piece of code of one program, then another, then a little code for WinAmp, then a little code for your program again, then more for Explorer etc...

L.O.K.
12-14-2002, 09:36 AM
Originally posted by Waldo2k2
what you're asking about has nothing to do with windows or dos programming, it's simply a matter of it being in c/c++.
You can write a program with several if statements or anything else you want, just as in windows. Here's an example program in DOS.


#include <iostream>
using namespace std;
//NEVER USE VOID MAIN, EVER!!
int main()
{
for (int i=0;i<=5;i++)
{
std::cout<<"hello"<<std::endl;
}
return 0;
}


this is only a process.
no program will run once like this.

it must in looping to check the mouse, key ....

Waldo2k2
12-14-2002, 12:41 PM
Originally posted by L.O.K.
this is only a process.
no program will run once like this.

it must in looping to check the mouse, key ....

damn are you stupid.
first you ask a question, then you smart off to those who (know more than you) and help you.
That program will run just fine, i don't have to check for the mouse or keys. Besides all i'd have to do is do cin>> whenever i want input from the keys.
What you said is like saying hello world doesn't work, does that check for keys?? NO.
>>no program will run once like this.
Jesus man, why don't you try compiliing it?

L.O.K.
12-15-2002, 09:38 AM
Originally posted by Waldo2k2
damn are you stupid.
first you ask a question, then you smart off to those who (know more than you) and help you.
That program will run just fine, i don't have to check for the mouse or keys. Besides all i'd have to do is do cin>> whenever i want input from the keys.
What you said is like saying hello world doesn't work, does that check for keys?? NO.
>>no program will run once like this.
Jesus man, why don't you try compiliing it?

OK.

TheUnheardHuman
12-15-2002, 11:44 AM
dude its quite simple they dont run at the same time they switch turns so quickly it seems theyre doing their **** at the same time. ie if you had 2 timers...

timer 1 will increment 1
timer 2 will increment 1
timer 1 will increment 1
timer 2 will increment 1
timer 1 will increment 1
timer 2 will increment 1
timer 1 will increment 1
timer 2 will increment 1

until it reaches wutever number

L.O.K.
12-17-2002, 03:25 AM
Originally posted by TheUnheardHuman
dude its quite simple they dont run at the same time they switch turns so quickly it seems theyre doing their **** at the same time. ie if you had 2 timers...

timer 1 will increment 1
timer 2 will increment 1
timer 1 will increment 1
timer 2 will increment 1
timer 1 will increment 1
timer 2 will increment 1
timer 1 will increment 1
timer 2 will increment 1

until it reaches wutever number

O., SEE.
thx.