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.

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Mar 2014 05:07 Edited at: 18th Mar 2014 06:11
Can anyone explain why the first 8 characters aren't being displayed?


This is how the output looks for me:


It displays fine as long as the print and sync commands are used inside the loop. Nevermind why I want to display info outside the loop, this is just an example of something else I was working on that shows another bug, which is as follows.


This example requires you to create an additional include file. The include file has a function to initiate variables for me (for a gui library I'm making). This function initializes a global variable which is used in other functions that increment its value. If that function returns the global value, then it registers as 0 outside the function. Remove the return value from the function and you'll see its value incremented in this example as expected. I just discovered that if I move the duh() function to the included file instead, then it would work fine and I can return the global value without issue.

main.agc



test.agc


Attachments

Login to view attachments
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 18th Mar 2014 07:55
Try doing your init in a gosub instead of a function. I'm not sure if you can declare a global in a function...

Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 18th Mar 2014 08:13
Yeah, I don't think you should declare globals in functions. Just declare it at the top of the included file. No function or gosub required.

And why are you returning thing in the duh() function?

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Mar 2014 08:14
the first thing, its because windows send a paint event
and i think its handled from agk in sync().
also user input updates there each call.

endfunction thing
should return a var from inside a function.
your thing is global u do not need as return value.

function duh()
inc thing //Global
endfunction

function duh()
ok=0
if blah=x then ok=1
endfunction ok

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 18th Mar 2014 09:49
Quote: "Can anyone explain why the first 8 characters aren't being displayed?"

The error is because the first call to sync acts peculiarly because of double buffering. If you change your code to

it should work fine.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Mar 2014 10:41
i believe the windows shared the desktop graphics memory.
if u move a form or change it size it need a refresh
and maybe the other windows too.
refresh means exchange the new painted backbuffer with frontbuffer if
double buffering is used.
exchange is faster than copy one to another.
means also you get trash from front in your backbuffer.
most nonsense from bygone days but had saved memory.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Mar 2014 11:43
My function adds so many elements to an array, possibly redimming it when necessary, hence for the global values. The function returns the current size of my array for user feedback, so they can know how many items were created at which index. The global variable itself is hidden from the user and used internally. It's nice to have my function return the array index as elements are added, it's more convenient than having to call a separate function to get the size during creation.

I've created globals inside functions before in a similar fashion and they work fine. This is the only issue I've run into. And it's not even a big problem, I just thought I'd point it out.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Mar 2014 12:09 Edited at: 18th Mar 2014 12:20
ahh,
maybe u need this
function duh()
inc thing
ret=thing
endfunction ret

its more save using global vars in a udt.
type TGlobal
thing
endtype
global g as TGlobal
g.thing=x

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Mar 2014 18:43 Edited at: 19th Mar 2014 18:51
Found another possible bug.




I added rootX/rootY to the UDT but it won't detect them. Thinking maybe they'd be some reserved word, I tried changing them to just x/y but got the same error. The other variables are just fine. I renamed the UDT to something else and it works now. It's like AppGameKit had cached an old copy of the UDT and wasn't recompiling my change.


Nevermind, I'm an idiot. I had copied the UDT to another file so I could reference it. Even so, it should have given me a duplication error.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-25 03:50:14
Your offset time is: 2024-11-25 03:50:14