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 / Pass default value in function variables

Author
Message
Chmava
6
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 21st Jun 2017 08:06 Edited at: 21st Jun 2017 08:10
How do i do this?



it keep giving me this error like function is absolutely useless?



i also tried::



now it just tell me i could not put a default value there?

any help or answer appreciated?
If it does not exists in the engine, then this engine is absolutely useless regardless of what other function it has...
Markus
Valued Member
15
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 21st Jun 2017 12:07 Edited at: 21st Jun 2017 12:11
function setFPS (fps)
setFPSEx (fps,0)

function setFPSEx (fps, mode)

or use a struct (type) variable by reference

type TFPS
fps
mode
endtype
function setFPS(fps ref as TFPS)

or make a feature request, i believe default values are not supported.
AGK (Steam) V2017.05.15 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Chmava
6
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 21st Jun 2017 12:11
that is what i found... *SIGH*...
How can function not have the ability for default values to be set...
Markus
Valued Member
15
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 21st Jun 2017 14:58
agree, its a nice to have.

other option is a if then in function scope.
if mode=0 then mode = 12345
AGK (Steam) V2017.05.15 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
tmu
2
Years of Service
User Offline
Joined: 2nd Feb 2017
Location:
Posted: 21st Jun 2017 20:53
I don't really miss default values since many programming languages don't have them. A nice bit of extra of course. But it seems we should put all variables in structs to go around all these limitations.

Most annoying for me is mixing global variables with locals and getting no notification or any other way to distinguish whether I am using a global or local. And no error if the variable was never defined. So Markus had another suggestion before to stick all variables in structs. I guess that might work as long as you always remember to refer through the struct variable. But to me this seems to tell about a more general problem with ability to structure the programs.

I considered using underscores in front of the variable names but on the OSX version of the AppGameKit IDE the underscores shows as a blank space. Boohoo. Maybe use capital letter for globals as in Go. But AppGameKit is case-insensitive. Boohoo again
blink0k
AGK Developer
Gold Codemaster
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Jun 2017 00:41
@tmu i find that if you use #option_explicit it helps a lot
tmu
2
Years of Service
User Offline
Joined: 2nd Feb 2017
Location:
Posted: 22nd Jun 2017 10:35
Um, thanks @blink0k! I had no idea that existed, I shall now enable it for all my code. I expect it will help a lot, even if not 100% fix for all .

Any other great pointers on stuff I probably have missed? Like write debug print statements into code, read them from the IDE after running it local or on broadcaster? A way to view and manage the media folder contents from the AppGameKit IDE? A hidden level editor with awesome features? Anything else..

PS sorry to have hijacked the thread..
blink0k
AGK Developer
Gold Codemaster
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Jun 2017 12:30
PartTimeCoder
AGK Tool Maker
4
Years of Service
User Offline
Joined: 9th Mar 2015
Location: Suffolk UK
Posted: 22nd Jun 2017 15:03
Quote: "Like write debug print statements into code, read them from the IDE after running it local "


Yeah, great for debugging complex code, I wrote this small plugin for a quick way to debug with some cohesiveness, it simply shows a window with a list of all debug output sent to it, only works on windows, it would be great to see something like this added to the IDE debug system without having to set breakpoints and add variables to the watcher, like sending output to the Debug Log pane would be the logical way to go.




allowing default values in function prams would be good to +1 for that

Attachments

Login to view attachments
Markus
Valued Member
15
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Jun 2017 17:53
Quote: "mixing global variables with locals and getting no notification"

if you using much globals put them
all into a type, so you have only one global variable
and can access all via dot.
AGK (Steam) V2017.05.15 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Wilf
Valued Member
13
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Doha, Qatar
Posted: 22nd Jun 2017 21:46
Hey PartTimeCoder, that's a very nice little plug-in. Thanks for sharing!
blink0k
AGK Developer
Gold Codemaster
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Jun 2017 22:07
Nice tip @markus.
Thanks for the plugin @PTC

Login to post a reply

Server time is: 2019-09-16 15:04:54
Your offset time is: 2019-09-16 15:04:54