It is currently Sun Mar 26, 2017 11:33 pm



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  [ 4 posts ] 
Author Message
 Post subject: New Discoverer
Unread postPosted: Mon Feb 13, 2017 1:21 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1288
Hi All

This is not a bug, but there is no forum topic for New Discoverers. :lol:

Whist working on an app I discovered that functions call from within an interrupt can access variables created outside of the function and they can modify variables created outside of the function. They work more like gosubs then functions.

To the best of my knowledge there is no mention of this in the manual.

If you run demo below all will become clear.

I guess the only person who could explain this is jMac or maybe xFox

Regards Roy

Code:
Rem Interrupts


fn.def BackKey()
    ?b$
    ?"Tom = ";tom
    ?"John = ";john
    if tom + john = 30 then ?"Sam = ";sam; : ?"  Sue = ";sue : end
fn.end

fn.def TomAndJohn()
    ?"In function TomAndJohn()"
    ?"Tom = ";tom
    ?"John = ";john
    if tom + john = 30 then end
fn.end

fn.def ShowVar()
    sam = sam + 1
    ?"Sam = ";sam
    call ShowVar2(3)
fn.end

fn.def ShowVar2(num)
    sue = sue + num
    ?"Sue = ";sue
    x = x + 10
    ?" x in ShowVar2 = ";x
fn.end

timer.set 2000
b$ = "Back Key Pressed"
sue = 5
sam = 1
tom = 10
john = 20
x = 5
call TomAndJohn()

do : pause 100 : until 0

onTimer:
    call ShowVar()
    ?"x in main loop = ";x
timer.resume

onBackKey:
   call BackKey()
back.resume



Top
 Profile  
 
 Post subject: Re: New Discoverer
Unread postPosted: Mon Feb 13, 2017 7:12 am 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 280
Hi Roy,

roy wrote:
This is not a bug, but there is no forum topic for New Discoverers. :lol:


Yes, this is a bug, because it should not happen :!: :!: :!:
Thank you for this important catch.

It seems to be, that in this case the variable allocation is broken until a RESUME command.

Gregor


Top
 Profile  
 
 Post subject: Re: New Discoverer
Unread postPosted: Mon Feb 13, 2017 11:45 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1288
Thanks Gregor

I thought you would have an idea what is going on. ;)

Regards Roy


Top
 Profile  
 
 Post subject: Re: New Discoverer
Unread postPosted: Mon Feb 13, 2017 2:50 pm 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 280
roy wrote:
Thanks Gregor

I thought you would have an idea what is going on. ;)

Regards Roy


See
http://rfobasic.freeforums.org/viewtopic.php?f=5&t=4408&start=40


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
suspicion-preferred