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 Studio Chat / New cool feature found with - '#constant '

Author
Message
sedrok
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 12th Dec 2021 18:35
New cool feature found with - '#constant '

check this:

Attachments

Login to view attachments
Seditious
10
Years of Service
User Offline
Joined: 2nd Aug 2013
Location: France
Posted: 12th Dec 2021 19:06
Constants are assigned at compile time, regardless of where you put the assignments in the code.
2002 - Present
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 12th Dec 2021 19:46
That is performing exactly as expected.
What is the new feature you think you've found?
sedrok
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 12th Dec 2021 21:20 Edited at: 12th Dec 2021 21:49
i thought it only for numbers and string and not for any expression

it's more like #define in c++, but cannot write function-like expressions kind of
#constant ttt(a,b) Print(a + b)

test this:
it's fun


PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Dec 2021 22:20
Just because you can, does not mean you should!

Unless you like unreadable code, then its fine!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Dec 2021 23:06 Edited at: 12th Dec 2021 23:07
Constants are a lot like serach and replace in the IDE except they are context sensitive (They won't replace in literals).
They are simple substitutions so;
a=1: b=2 c=3: ttt
becomes
a=1: b=2 c=3: Print("Hello"+ a + b + c)
Then it is compiled.

Login to post a reply

Server time is: 2024-04-19 00:58:31
Your offset time is: 2024-04-19 00:58:31