10-03-2009 11:31 PM
ok my program dont wont to end , after the comport is not open, it continues and keep running the for completely
the program suppose to shut down after the first error
can some one assist me?
10-04-2009 04:14 AM
yes, that's true it does not end, i can see it only by reading the code.
and no, it is not supposed to end after the first error...
you wrote:
[...]
status_check = OpenComConfig (physical_port, "COM10", baudrate,
parity, databits, stopbits, inputq, outputq);
switch_errors();
for(counter=0;counter<3;counter++)
{
[...]
please, place a breakpoint into your switch_errors() function, then use the "step" function until the end of the software to see what is happening.
it seems you misunderstood the meaning of the return keyword (once again, i will point you toward a good programming course...). the return keyword makes the program exit the current function, in your case it exits switch_errors(), but the program continues to execute where the function was called, in your case it executes the for loop just after the switch_errors() call.
(by the way, the return keyword has the same meaning in C++... if you see what i mean...)
10-04-2009 10:34 AM
now that i think about it, exit(0); will work. it works.
i always new that return 0; mean the program ended successfully
10-04-2009 04:10 PM - edited 10-04-2009 04:11 PM