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 / Functions and UDTs

Author
Message
DrT
16
Years of Service
User Offline
Joined: 10th May 2008
Location: 26.78 degrees North, -70.49 degrees West
Posted: 15th Aug 2011 21:02
Do functions accept UDTs?

Can functions return UDTs?
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 16th Aug 2011 06:10
Yes and Yes Try it out!

I drink tea, and in my spare time I write software.
DrT
16
Years of Service
User Offline
Joined: 10th May 2008
Location: 26.78 degrees North, -70.49 degrees West
Posted: 16th Aug 2011 12:24
Thanks Lee.

Maybe you can help me with the following chunk of code then. It compiles without error, but the exe stops working (windows message) when I compile, run and broadcast.

type playerType
name$
score
endtype

player1 as playerType

player1.name$ = "Bob"
player1.score = 100

do
showPlayer(player1)
sync()
loop

function showPlayer(player as playerType)
print(player.name$)
print(player.score)
endfunction
BiggAdd
Retired Moderator
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 16th Aug 2011 13:40
I've had the same problem DrT, I've reported it in here:
http://forum.thegamecreators.com/?m=forum_view&t=188136&b=41

But you should do also

However, returning a UDT from a function works fine!

LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 16th Aug 2011 15:04
And even more simpler, this crashes too:

type playerType
score
endtype
player1 as playerType
player1.score = 100
do
showPlayer(player1)
sync()
loop
function showPlayer(player as playerType)
print(player.score)
endfunction

Will deal for the next build, thanks.

I drink tea, and in my spare time I write software.
DrT
16
Years of Service
User Offline
Joined: 10th May 2008
Location: 26.78 degrees North, -70.49 degrees West
Posted: 16th Aug 2011 22:28
Thank you BiggAdd and Lee.
DrT
16
Years of Service
User Offline
Joined: 10th May 2008
Location: 26.78 degrees North, -70.49 degrees West
Posted: 1st Sep 2011 02:36
I define a UDT with a string field. I then set this field in a function and return the UDT. The returned UDT now has an empty string field. Is this a bug or am I overlooking something?

LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 5th Sep 2011 04:36
I can confirm this as a bug in 1.0.3.6. I will see what I can do about a good bug reporting system to capture these. Watch this space!

I drink tea, and in my spare time I write software.
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 5th Sep 2011 04:41
For future reference, the new home for all AppGameKit bugs is here: http://code.google.com/p/agk/issues/list

I drink tea, and in my spare time I write software.

Login to post a reply

Server time is: 2024-11-24 00:17:25
Your offset time is: 2024-11-24 00:17:25