Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Argument is the wrong type
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
progammin_nub




PostPosted: 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.. Crying or Very sad
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sat Jun 03, 2006 10:04 pm   Post subject: (No 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:
code:
var del : real := 460.3
delay (del)

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:
code:
var del : real := 460.3
delay (round(del))
TheOneTrueGod




PostPosted: Sat Jun 03, 2006 10:09 pm   Post subject: (No subject)

It means you are trying to assign a value to something that isn't of that type.

For example:

code:

var x : int
x := "hi"


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 Very Happy.
progammin_nub




PostPosted: Sat Jun 03, 2006 10:16 pm   Post subject: Program

Here's my program


summative.t
 Description:

Download
 Filename:  summative.t
 Filesize:  5.2 KB
 Downloaded:  208 Time(s)

TheOneTrueGod




PostPosted: Sat Jun 03, 2006 10:27 pm   Post subject: (No subject)

Well, i'm getting an error in the actual GUI module, which leads me to believe this was something wrong with Turing Razz. I personally have never used GUI, i've allways just created my own, but I tried scanning through the GUI code, and I couldn't figure out why it was doing that. My suggestion is to not use GUI, or figure out what the last thing you changed before you got that error was. Once you know what that is, you can start commenting out lines until you don't get the error anymore. Then, find another way around the problem, so it doesn't cause an error.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: