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 / Hands On AGK BASIC: User-Defined Functions

Author
Message
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 13th Sep 2013 16:20
I have found the Hands on AppGameKit BASIC book very useful but I am a bit puzzled about why I get no result with this program from FIG-8.1, page 194 in the book.

rem *** main program ***
DrawLine()
Sync()
do
loop
end
rem *** Draw a line function ***
function DrawLine()
Print("**********")
endfunction

When I run it, the Application window opens but stays blank.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 13th Sep 2013 16:22
You now need to have the Sync() statement inside the do loop. As well as any print statements. This changed with v108 betas, after the book was written. In v1076, the posted example would work.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 13th Sep 2013 16:35
When I put Sync() into the do loop, on the line below do and above loop, it has no effect. Stll nothing printed. When I click help/about I am told that I have build: 107. I had trouble before with v108 beta and had to go back to v1076
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 13th Sep 2013 16:43 Edited at: 13th Sep 2013 16:47
As Ancient Lady pointed out, you also need to move the Print Statement. Try this;



EDIT: @AL,
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 13th Sep 2013 16:44 Edited at: 13th Sep 2013 16:44
Given the code you started with, you need to move both the Drawline function call and the Sync call inside the loop.

Anything output from a Print statement only exists for one Sync cycle and then disappears.

EDIT: Ninjaed by Funnell7!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 13th Sep 2013 16:51
Thanks a lot. All is now well
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 13th Sep 2013 18:18
Quote: "You now need to have the Sync() statement inside the do loop. As well as any print statements. This changed with v108 betas, after the book was written. In v1076, the posted example would work."


Also, the built-in DrawLine function was introduced in AppGameKit Build 1083.

So, the "DrawLine" function that is defined in the example would override the built-in DrawLine() function.

I'm sure Alistair will one day get around to updating the examples in the PDF-version of the book.

Cheers,
AgentSam

Login to post a reply

Server time is: 2024-11-24 19:46:13
Your offset time is: 2024-11-24 19:46:13