![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Having problems displaying a line of variable length using winio.I have the problem of creating a program to give the option of selecting a shape(line,rectangle,circle,ellipse) then specifying the dimensions in a pop up window. After putting in the values a button will refresh the screen showing the object. Im having problems managing to get the line to be drawn "Run-time Error:The function supplied as arguement 2 is corrupt". Im also pretty sure that i shouldnt have to put a ";" after DLine() but it errors otherwise.
CPP / C++ / C Code:
|
|
#2
|
||||
|
||||
|
Hi Warny.
I am afraid that I am not going to be much help as I have never used the winio functions. Your code is always so easy to read and so well formatted that I always want to help but unfortunately I may not have the background to help. Let me ask you a couple of questions though and maybe we can figure something out. What is DLine()? You have it defined here as a function that returns an integer: CPP / C++ / C Code:
When you call it here, it seems like DLine is a variable, did you mean to call it this way or should it be called as a funcion, ie DLine() CPP / C++ / C Code:
I think I may have just figured something out. Isn't DLine() a function that you declare here? CPP / C++ / C Code:
Is that why you think it shouldn't have a semicolon. You are right & wrong. You need to define this function outside of your main function. So, above or below your main function, just put it as: CPP / C++ / C Code:
One more quick thing. Have you thought about using a case/switch statement? It is not a huge thing, but using a row of ifs like this causes the program to check for the value, even after it has found the right one. I hope something here helps.... |
|
#3
|
|||
|
|||
|
Iv used Dline() before, although it can b called anything u want, its just like main() as its just an area in which a process takes places which is y it doesnt need a ";", and i simply use a pointer to let the program know where to find it.
Iv worked on my code while trying to post my reply and while sticking varias parts of programs iv done before i managed to get something that works: CPP / C++ / C Code:
|
|
#4
|
||||
|
||||
|
Hi warny. I am glad to see you making progress with this. I know I can't be of much help because of the winio library you are using.
![]() I would like to make a comment and if I am wrong I hope that someone will point it out. I don't think that standard C syntax allows for inline function declarations like you are showing. I personally have never seen them in C and I can't compile anything like that. Your current compiler may allow this, but most compilers won't. What compiler are you using? Visual C++? The use of functions is excellent, but these should be defined outside of your main loop. Anyway, it is your program not mine, so you can do it the way that you are most comfortable. I thought I just might mention this. |
|
#5
|
|||
|
|||
|
Im using Salford compiler, not my personnal choice butbeing able to use windows.h makes the program look nice and professional even if its not. This is my finished program,although im not sure how useful it will b to anyone seeing as iv got a compiler with different directories:
CPP / C++ / C Code:
Which functions could i define outside the main loop? |
|
#6
|
||||
|
||||
|
Okay, my world has returned to normal now.
![]() You are *not* using in-line function definitions. There was a small difference in what you posted this time: CPP / C++ / C Code:
Compared to last time: CPP / C++ / C Code:
Do you see where my confusion was? Actually, I appreciate you posting your code. I am sure that there are others that use the winio library. Have you looked at using a switch/case statement? It would be set up like: CPP / C++ / C Code:
instead of doing several comparisons, you are doing only one, and then your code is jumping to that point. |
|
#7
|
|||
|
|||
|
Quote:
Thanks for the help the switch statement makes the code neater and iv understood how to use it properly seeing as when i used it b4 i just ripped it off someone elses script. This is my script now: CPP / C++ / C Code:
|
|
#8
|
||||
|
||||
|
Looks good!
A couple of things on the switch statement. The { } are not required on the case statement, but they don't hurt anything. Basically a case statement will run until it hits a break, therefore things like CPP / C++ / C Code:
|
|
#9
|
|||
|
|||
|
Thanks for all the help my code looks alot better now.
|
Recent GIDBlog
Observations of Iraq by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CD Burner Help - Power Calibration Error.... | JonBoy420 | Computer Hardware Forum | 110 | 05-Feb-2008 18:34 |
| burning problems PLEASE PLEASE HELP | kelticeire | Computer Hardware Forum | 4 | 01-Dec-2006 15:39 |
| Having a problem | Chuckles | Computer Hardware Forum | 19 | 13-Sep-2004 12:17 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 11:28 |
| CD Buring Failed | skanth2000 | Computer Hardware Forum | 1 | 15-Nov-2003 03:52 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The