Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / String / Integer Variables

Author
Message
JazzSPX
8
Years of Service
User Offline
Joined: 26th Jun 2015
Location:
Posted: 15th Jul 2015 02:27
Hey All

Another n00b question

I'm trying to use a variable to save me some lines of code when loading in some sprites, just to save on typing (or copy pasta) if nothing else...

Anyways...



Basically, I'm saying 'ScoreNoLoad' is an Integer in one instance and then trying to use it in a String as well, AppGameKit doesn't like it - Incompatible Types

Something I'm missing? - I was planning on doing this a fair bit to load Sprite Animations and the like :/
Maghnus
8
Years of Service
User Offline
Joined: 12th Jul 2015
Location:
Posted: 15th Jul 2015 02:52
I'm new here as well, so I may be mistaken, but I think the scripting language only allows for connecting a string with another string directly. I think you need to prefix your non-string variables and literals with Str( var ) to typecast them as strings. http://www.appgamekit.com/documentation/Reference/Core/Str.htm
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 15th Jul 2015 03:07 Edited at: 15th Jul 2015 03:20
Try str(ScoreNoLoad) to convert the integer to a string.



You could use int(mystring$) to convert a string to an integer.
That is what I do for my race track data file.
The file is 256 lines of numbers, but read in as an array of strings then converted to numbers for processing, then back to strings for paths.
My track section images have file names with numbered appendages, and I construct the file name for the images the same way as above.


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
JazzSPX
8
Years of Service
User Offline
Joined: 26th Jun 2015
Location:
Posted: 15th Jul 2015 20:01
Quote: "I'm new here as well, so I may be mistaken, but I think the scripting language only allows for connecting a string with another string directly. I think you need to prefix your non-string variables and literals with Str( var ) to typecast them as strings. http://www.appgamekit.com/documentation/Reference/Core/Str.htm"


Quote: "Try str(ScoreNoLoad) to convert the integer to a string. "


Brilliant - Worked like a charm, thanks!

Login to post a reply

Server time is: 2024-04-26 05:35:25
Your offset time is: 2024-04-26 05:35:25