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 / Variable declaration inconsistent

Author
Message
Carharttguy
10
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 6th Mar 2017 10:33
Hello

I stumbled upon this: Variable declaration via characters is not the same as via "As Float".
This code works fine:


But this doesn't:



This is the alternative:



That's kind of redundant, isn't it?

I know I could just use the # way of defining a value, but I like the "As Float" much more, way more readable IMO.

Paul: Is there a way for you to make this consistent? So that we can assign values directly via the "As Type" way?
easter bunny
13
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 6th Mar 2017 11:20
Quote: "but I like the "As Float" much more, way more readable IMO."

I concur.
And yeah it does seem kinda strange that your cant initialise it that way tbh I wouldn't mind one bit if AppGameKit added the functionality to declare variables the same way they're done in OO languages (alongside the current way for redundancy and peoples habits)

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting
Markus
Valued Member
22
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Mar 2017 12:19
agree.

you can use shortcuts like this
type ff tab
see snippets.conf

[AGK]
ff=local %cursor% as float

AGK (Steam) V2017.02.28 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
PSY
Developer
10
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 6th Mar 2017 23:22
Concur 2

I always use


It's simply clean and doesn't allow much space for mistakes.


All my floats are marked with a '#', and all variables are fully declared, like so:




Cheers
PSY
PSY LABS Games
Coders don't die, they just gosub without return
Richard_6
9
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 7th Mar 2017 01:45 Edited at: 7th Mar 2017 01:46
I also like using #option_explicit. It's becomes really handy after some time! It's easier to find errors too.
Paul Johnston
TGC Developer
23
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 8th Mar 2017 16:30
Quote: "joystick_x As Float = GetJoyStickX()"

Assigning values to declarations can only use literals as it is parsed by the compiler, which then stores the default value in the bytecode, so it must be a static value. This is mainly to allow declaring of variables with default values in parts of the code that will never be executed, such as included files.
Carharttguy
10
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 10th Mar 2017 14:48
Thanks Paul, nice to know!

Quote: "you can use shortcuts like this
type ff tab
see snippets.conf

[AGK]
ff=local %cursor% as float"


Thanks for the tip, I have almost everything in snippets.conf now, like If..EndIf, Function..EndFunction and so on!

Login to post a reply

Server time is: 2026-07-14 00:55:24
Your offset time is: 2026-07-14 00:55:24