Computer Science Canada Argument is the wrong type |
Author: | progammin_nub [ Sat Jun 03, 2006 9:59 pm ] |
Post subject: | Argument is the wrong type |
What does this type of error means? I often have problems with this error a lot. And I don't know how to correct my mistakes.. ![]() |
Author: | [Gandalf] [ Sat Jun 03, 2006 10:04 pm ] | ||||
Post subject: | |||||
Why don't you show us some example code where you get this error. Let me give you an example then... Let's say you wanted to delay the program for a variable amount of time, which was a real number. For example:
This will give you an error, because the delay procedure takes an integer as an argument, not a real number. To solve this error you will have to round the real numer:
|
Author: | TheOneTrueGod [ Sat Jun 03, 2006 10:09 pm ] | ||
Post subject: | |||
It means you are trying to assign a value to something that isn't of that type. For example:
Obviously this won't work, because x is not a string, its an int. But you are trying to set x to a string. The Turing compiler realises this shouldn't (and can't) happen, so it whines to you to fix it. The same thing happens with any variable type. Strings must be strings, they cannot be ints, booleans, etc... The different types of variables (That I can think of, and that exist in Turing) are: int, real, boolean, string, char These are the most common ones that you will probably use. There exist more, but I cannot think of them at the time. reals and ints are special, however. Any Integer is a real, but a real is not necessarily an integer. The reasons should be obvious (3 is the same as 3.0, but 3.3 cannot be expressed as a whole number, without using scientific notation) You can transform variables from one type to another using special turing functions, and in other langauges you can typecast variables. To transform variables from one variable type to another, investigate the following functions: strint intstr strreal realstr or create your own function ![]() |
Author: | progammin_nub [ Sat Jun 03, 2006 10:16 pm ] |
Post subject: | Program |
Here's my program |
Author: | TheOneTrueGod [ Sat Jun 03, 2006 10:27 pm ] |
Post subject: | |
Well, i'm getting an error in the actual GUI module, which leads me to believe this was something wrong with Turing ![]() |