10-01-2009 01:25 AM
hi roberto, im not getting no errors at all, im trying to getting rid of my if statements, im trying to make my code look neat.
so im trying to format my code so that people can understand. so just this session of the code is horrible, i have to many if statements
which is nothing wrong.
so im trying to come up with the logic of how im going to format all my error handling , thats whats generating my code to look like it is.
so maybe im thinking of a switch statement ,but im trying to map the logic out now.
ok tis what im trying to do,on the next slide i will show you what have and what i want to do.
****************************************************************
10-01-2009 01:35 AM
10-01-2009 04:39 AM
10-01-2009 07:58 AM - edited 10-01-2009 08:00 AM
Darnell:
I'm wondering why you keep asking for our advice when you don't take our suggestions.
I asked you to post .c files, not .docx files, but the next code you post is .docx. Doing that makes it harder for some people to read your posts, so it's harder to help you. You should not want to make it harder to help you. If you are entering code at home and don't have CVI installed there, you can use Word as a word processor, but save it as a text file with a .c extension.
I told you that even though you're calling GetRS232ErrorString (), you're not using the string it returns. Well you're still not.
I'm really puzzled that your criteria for asking for help is that you don't like the way the code looks, but you're not addressing functional problems in the code. I'd suggest that at this point, your code would look fine if you correct the problems we already pointed out.
P.S. If you're using Word because you're working from home and don't have CVI there, NI has a home-use license: if you have NI products installed on your machine at work and no one is using them when you're not there, you can install those NI products on one machine at home under the same license. See some license info here: http://www.ni.com/license/licensing_options.htm
10-02-2009 10:59 AM
i started a new project to test something out.
i like this format better with the switch statement i was using, the code looks more cleaner.
but i'm having one problem . the code only display the last condition, instead of all three conditions im test for.
check the attachment. but you see where im heading
10-02-2009 11:07 AM
also i just notice one thing also that my if statement was wrong in the display error, this is the correct one
if(status_check<0)
{
RS232Error=GetRS232ErrorString(status_check);
sprintf(ErrorMessage,
"RS232 Error Message %d\n\n",RS232Error);
MessagePopup ("RS232 Error Message", ErrorMessage);
DEBGPRNT(ErrorMessage);
}
10-02-2009 11:27 AM
10-02-2009 12:02 PM - edited 10-02-2009 12:07 PM
Darnell:
I don't see anything wrong with the structure of your switch statement. I'm not sure what you mean by "the code only display the last condition, instead of all three conditions im test for". It looks like you're checking for 4 cases, plus the default. I see that you have breakpoints set in your switch statement. But you won't hit any of the breakpoints unless your status_check is one of those 4 errors. Have you tried a breakpoint on your ComRd statement to see what it is actually returning?
You may be writing this code only for practice using the switch statement, but you don't need switch statements if you're doing the same thing for all your cases. Why specifically look for -2, -03, -4, and -7 if you'll do the same thing for any of them?
You are right about needing %s to display RS232Error. But as Roberto pointed out earlier, you don't really even need to create the RS232Error variable: you can use the GetRS232ErrorString functions directly in your sprintf function.
I'm sorry if you're tired of me whining, but both Roberto and I have asked you previously not to post your cvibuild directory, .exe file, and .cdb file. But you did it again.
10-02-2009 12:16 PM
if you look in the code im using it. the is how im using it.
RS232Error=GetRS232ErrorString(status_check);
but for some reason its only catch error -3.
its nothing catching the -7 error when im opening the comport, the compiler is catching it but my switchment is not catching it.
but yeah i was using this three days ago. check the attachment early that i posted recently
10-02-2009 04:10 PM
can you tell me why in my switch statement my program is not closing after the first -7,
the program only close when it get the comrd. im steping through it but its not reading my return 0 when get to
the -7 case, it keeps going all the way to the comrd. why is that