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 / Default value for function?

Author
Message
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 19th Dec 2018 05:04 Edited at: 19th Dec 2018 05:05
I searched, there is nothing.

I need something like this: function xxx (a = 1, b = 2, d = , f# = 0.0, g$ = "xxx" )

All the error claim was: error: Cannot assign a default value here

Any reply appreciated!
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Dec 2018 13:16
AGK doesn't have this ability as functions and parameters cannot be overloaded.

Best option I think is to set up some default constants.

#CONSTANT FN_XXX_A = 1
#CONSTANT FN_XXX_B = 2
#CONSTANT FN_XXX_F = 0.0
#CONSTANT FN_XXX_G = "xxx"

xxx(7, FN_XXX_B, 3, FN_XXX_F , FN_XXX_G)

Yea it's not as pleasant as just being able to leave out the parameters you're not altering, but I don't see another way.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 19th Dec 2018 14:40
What is the different between this and global variables?
The same reset is needed at the end of the function?
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Dec 2018 14:46
Global variables can be changed. So unless you plan on changing these default function parameter values dynamically, which wouldn't be possible in the method you wanted anyway as it's assigned during function declaration, then constants make more sense.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 20th Dec 2018 02:01
Will assigning value to it change it to be usable?

Login to post a reply

Server time is: 2024-03-28 13:17:28
Your offset time is: 2024-03-28 13:17:28