It is currently Fri May 26, 2017 12:19 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 6:27 am 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
this works:

Code:
BUNDLE.CREATE global
BUNDLE.PUT 1,"key","abc"
TIMER.SET 1000
DO : UNTIL 0

ONTIMER:
BUNDLE.GET 1,"key",a$
? a$
TIMER.RESUME


the problem doesn't seem in ONTIMER.

/ L


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 6:32 am 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
this works too:

Code:
FN.DEF f()
  BUNDLE.GET 1,"key",a$
  ? a$
FN.END

BUNDLE.CREATE global
BUNDLE.PUT 1,"key","abc"
TIMER.SET 1000
DO : UNTIL 0

ONTIMER:
f()
TIMER.RESUME


the problem must be somewhere else.


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 7:23 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
Code:
include "GW.bas"
p=gw_new_page()
t=gw_add_title(p, "No button hit")
gw_add_button(p, "Gw_Modify in main routine", "0")
gw_use_theme_custo_once("style='color:white; background:red'")
gw_add_button(p, "Gw_Modify in OnTimer", "1")
gw_render(p)
do
r$=gw_wait_action$()
if r$="0"
?"Gw_Modify in main routine:"
?"last control id = gw_key_idx(\"control\") = ";gw_key_idx("control")
?
gw_modify(t, "text", "White button hit")
elseif r$="1"
timer.set 100
end if
until r$="BACK"
end

ontimer:
?"Gw_Modify in ontimer:"
?"last control id = gw_key_idx(\"control\") = ";gw_key_idx("control")
?
gw_modify(t, "text", "Red button hit")
timer.resume

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 7:24 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
the problem is in user defined function called from another udf in OnTimer, at least in GW (maybe it's to big and there's a memory problem?)

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 8:15 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
even more obvious in this snippet:
Code:
fn.def changetext(t)
gw_modify(t, "text", int$(256*rnd()))
fn.end

include "GW.bas"
p=gw_new_page()
t=gw_add_title(p, "No button hit")
gw_add_button(p, "Gw_Modify in main routine", "0")
gw_use_theme_custo_once("style='color:white; background:red'")
gw_add_button(p, "Gw_Modify in OnTimer", "1")
gw_render(p)
do
r$=gw_wait_action$()
if r$="0"
changetext(t)
elseif r$="1"
timer.set 100
end if
until r$="BACK"
end

ontimer:
changetext(t)
timer.clear
timer.resume


There's something I can't explain happening to the bundle #1 and I don't like it. We need jMarc expertise on this memory abnormality, until then I will go back to something that doesn't cause any problem.

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 10:57 am 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
Yes, nasty bug, you should raise an issue on GitHub.
Wondering if it's the same bug with all the other interrupts.
Would be good to create a snippet which reproduces the bug without GW.bas.

/ L


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 11:28 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
I found the issue and way to reproduce out of GW:
Code:
BUNDLE.CREATE global
BUNDLE.PUT 1, "abc", "def"

FN.DEF DisplayBundleKey(key$)
  BUNDLE.GET 1, key$, value$
  PRINT key$;" -> ";value$
FN.END

FN.DEF dummy(param$)
  key$ = param$ % same variable name 'key$' as used in DisplayBundleKey() function
  DisplayBundleKey("abc")
FN.END

PRINT "Get Bundle #1 value from main program:"
dummy("123")
PRINT

PRINT "Get Bundle #1 value from OnTimer:"
TIMER.SET 100
DO: PAUSE 1: UNTIL 0

ONTIMER:
TIMER.CLEAR
dummy("123")
END "Done"


This displays
Code:
Get Bundle #1 value from main program:
abc -> def

Get Bundle #1 value from OnTimer:
123 not in bundle
bundle.get1,key$,value$


The namespaces are all mixed-up when ONTIMER: is involved.
key$ inside DisplayBundleKey() should be "abc" as passed by parameter, but somehow it ends up being "123", from a different namespace (the dummy() function).

Well, this is not an easy problem and I remember Marc talking about it many times and I don't think there's an easy fix :(

The "best" I can do is use different variable names so they don't get mixed, but I'm not sure it'll even work and above all it's an ugly workaround, not a good solution.

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 11:40 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
Yeap using different variable names solves it, so it's an ugly workaround but at least it works...
Code:
BUNDLE.CREATE global
BUNDLE.PUT 1, "abc", "def"

FN.DEF DisplayBundleKey(key$)
  BUNDLE.GET 1, key$, value$
  PRINT key$;" -> ";value$
FN.END

FN.DEF dummy(param$)
  dummy$ = param$ % DO NOT use variable name 'key$' already used in DisplayBundleKey() function
  DisplayBundleKey("abc")
FN.END

PRINT "Get Bundle #1 value from main program:"
dummy("123")
PRINT

PRINT "Get Bundle #1 value from OnTimer:"
TIMER.SET 100
DO: PAUSE 1: UNTIL 0

ONTIMER:
TIMER.CLEAR
dummy("123")
END "Done"
displays
Code:
Get Bundle #1 value from main program:
abc -> def

Get Bundle #1 value from OnTimer:
abc -> def
Done

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 11:59 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
Tested the fix in GW lib V4.5 and Gilles's program works correctly, no more regression.

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: GW V4.5 error
Unread postPosted: Sat Dec 10, 2016 3:41 pm 
Offline

Joined: Wed Feb 20, 2013 3:25 pm
Posts: 423
Location: Italy
Very well done!
It seems this GW team is becoming rather efficient :lol:

So what's the rule? inside interrupt routines nested functions share a single variable namespace?
If so, then maybe a note could be put in the manual in the "Interrupt Labels" section...
(In this way we could avoid in the future re-discovering this behaviour from time to time the hard way)

So, after all, the refactoring done in GW 4.5 can be kept? I hope so.
Then it seems that 4.6 is becoming quite urgent :D
(Wondering if it will contain even some appetizer of your uniform rendering investigations? ;) )

/ L


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2, 3  Next


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
suspicion-preferred