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.

AppGameKit Classic Chat / Cannot assign String to Integer

Author
Message
roser137
9
Years of Service
User Offline
Joined: 23rd Apr 2015
Location:
Posted: 23rd Apr 2015 22:45
Hi. I just started to use AGK. I am not so new in programming but I have issue with types. Here is my code:




on line
compiler gives error:

variabled named platform is not defined elsewhere. I couldn't find any thing related to int type but compiler thinks variable platform is a integer and refuses to assing return value of GetDeviceName() function.
Harlequin
14
Years of Service
User Offline
Joined: 22nd Mar 2010
Location: Melbourne (AU)
Posted: 24th Apr 2015 09:18
Hi Roser137,

you need to make the "platform" variable a string as you are trying to store a string there and want to treat it as a string.

Here is the updated code (note the $ symbol now telling the compiler "platform" is a string).

I think when you declare and use variables in one statement, the compile does get a bit confused a defaults to integer type.

Declaring your variables before use is a better way to do this (at least that's what I was taught 20 years ago)



cheers

It's late, I'm tired, out of coffee and now I'm wet.

Login to post a reply

Server time is: 2024-04-25 11:34:50
Your offset time is: 2024-04-25 11:34:50