Computer Science Canada

Typecasting in Turing

Author:  DtY [ Wed Apr 22, 2009 7:03 pm ]
Post subject:  Typecasting in Turing

What is it you are trying to achieve?
Convert an integer to a string so I can attach it to a string using +


What is the problem you are having?
I need to set the screen size based on the size of the level loaded, when I add the size using + in setscreen(), I get the error that strings and integers cannot be added together.


Describe what you have tried to solve this problem
* Searched the forum (of course)
* using +, described above
* string(levelWidthPx), which would work in some other languages, told me that string() needed a value known at compile time
* Looked for another function that would take two integers, and only set the screen size.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
None

Please specify what version of Turing you are using
Newest version, 4.1.1, I think.

Author:  DemonWasp [ Wed Apr 22, 2009 7:21 pm ]
Post subject:  RE:Typecasting in Turing

intstr() . Similarly, realstr(), strreal(), strint(), etc.

Kudos for the excellent problem description, incidentally, that reads much better than the majority of the posts in this forum.

Author:  BigBear [ Wed Apr 22, 2009 7:26 pm ]
Post subject:  RE:Typecasting in Turing

you can either create a new variable which is assigned to the intstr of the number then add the string to you new variable or make a string varible = intstr of the num + string

Author:  DtY [ Wed Apr 22, 2009 7:34 pm ]
Post subject:  RE:Typecasting in Turing

Thanks both of you Smile
I will try that tomorrow in class, and I'll post if it doesn't work

Author:  BigBear [ Wed Apr 22, 2009 8:18 pm ]
Post subject:  RE:Typecasting in Turing

You can use the link at the top of the page to download turing

Author:  Dusk Eagle [ Wed Apr 22, 2009 10:32 pm ]
Post subject:  Re: Typecasting in Turing

Also check out strintok() and strrealok().


: