It is currently Sun May 28, 2017 5:15 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  [ 90 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Author Message
 Post subject: Re: Hot summer of code
Unread postPosted: Sat Feb 11, 2017 9:54 am 
Offline

Joined: Tue Jan 24, 2017 10:28 pm
Posts: 32
Your code is clean,very human readable. Kuddos..excelent example file.


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Mon Feb 13, 2017 2:42 pm 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 327
Roy discovered global variables after an interrupt.
See
http://rfobasic.freeforums.org/viewtopic.php?f=7&t=4891

At each function call BASIC! creates a new local symbol table.
:idea: After an interrupt BASIC! use the global symbol table, because BASIC! need in this case access to all variables.
BASIC! pushes all interrupts in a Stack. Only until all interrupts are closed with RESUME the local symbol table is used again.
That is not described in the manual :o :( :o
Maybe you get in trouble if you use a function before the interrupt stack is empty.
That should not be happen. :!:
So I added
LOCALS.ON % Now the variables in functions are definitely LOCAL
LOCALS.OFF % Now the variables in functions are only LOCAL if BASIC!s interrupt stack is empty.

Code:
REM Interrupts and trouble with new unwished GLOBALS

FN.DEF BackKey()
?b$
?"Tom = ";tom
! NEW !
LOCALS.ON
?"John = ";john
% If the variables are local the sum of tom + john should be 0
?"Tom + John = "; tom + john
! NEW !
LOCALS.OFF
?"Tom + John = "; tom + john
IF tom + john = 30 THEN ?"Sam = ";sam; : ?"  Sue = ";sue : 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 , xMain
FN.RTN x
FN.END

TIMER.SET 2000
b$ = "Back Key Pressed"
sue = 5
sam = 1
tom = 10
john = 20
x = 5

DO : PAUSE 100 : UNTIL 0

ONTIMER:
! NEW !
LOCALS.ON % Now the varaiables in ShowVar2 are LOCAL
xMain = ShowVar2(4)
?"x in main loop = ";x , xMain
! NEW !
LOCALS.OFF % Now the varaiables in ShowVar2 are LOCAL if BASIC!s interrupt stack is empty.
TIMER.RESUME

ONBACKKEY:
CALL BackKey()
BACK.RESUME

For a better understanding try to comment out the LOCALS.ON and LOCALS.OFF lines.

:idea: :idea: :idea:
On the other hand you are able to get your wished global variables, if you first create an interrupt. :mrgreen:
The only condition is, do not close this interrupt :mrgreen:
IF you need local variables in your functions use LOCALS.ON and LOCALS.OFF :mrgreen:
Do you think this is uncommon? Yes it is, but the BASIC dialect CA-REALIZER do this nearly in the same way in the early 90's.

Code:
REM Interrupts, Globals, LOCALS

FN.DEF ShowVar()
sam = sam + 1
?"Sam = ";sam
CALL ShowVar2(3)
FN.END

FN.DEF ShowVar2(num)
LOCALS.ON % Now the following variables are LOCAL
sue = sue + num
?"Sue = ";sue
x = x + 10
?" x in ShowVar2 = ";x
LOCALS.OFF % Now the following variables are GLOBAL if the last and final interrupt is not cancelled!
FN.END

TIMER.SET 10
firstTimer = 1
sue = 5
sam = 1
x = 5

Main:
DO
PAUSE 1000
ShowVar()
UNTIL 0
END

ONTIMER:
IF firstTimer = 1
TIMER.CLEAR
GOTO Main %So no RESUME and all variables are now GLOBAL
firstTimer = 0
ENDIF
! Maybe more other timer handling
TIMER.RESUME


You can download this test version under
https://github.com/RFO-BASIC/Basic/files/772466/OliBasicXII.zip

Happy coding
Gregor


Last edited by aFox on Fri Feb 17, 2017 12:52 pm, edited 2 times in total.

Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Mon Feb 13, 2017 4:17 pm 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 327
Evolbug wrote:
how about explicitly definable global variables?

GLOBAL var

because having everything global is a terrible idea


Maybe, but you can definitely with locals.on and locals.off, if my code is correct.
Trust me, I have experience!
Experience is the sum of failures!

Do not forget locals.on and locals.off, if you need them. :!: :!:

Gregor


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Mon Feb 13, 2017 10:55 pm 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Excellent Gregor

Thanks for the explanation and new commands ;)

Regards Roy


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Tue Feb 14, 2017 9:03 am 
Offline

Joined: Tue Jan 24, 2017 10:28 pm
Posts: 32
I love that phrase in Afox's signitre.

Exerience is the sum of failures.

Love that,so true.

I now try to write each code section 5-25 times those that pass the inturpreter error trap I then run against a execution timer. Most speghetti coderz will never understand the reasoning. Some of you will. And the word rigor how it could be defined with a multiplicity of definitions.


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Thu Feb 16, 2017 2:05 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Hi Gregor

I use the SciTE editor and when you press 'F5' the app you are working on runs on BlueStacks or you device, which ever you are using. But it runs on the official version of BASIC!

I would like to press 'F5' and it run on your version. Also I would like to be able to make an APK with your version.

I sure others would like to do the same.

The last time I asked this question I was pointed the this link:
viewtopic.php?f=4&t=4710&hilit=tools

Unfortunately I didn't get any where with that.

Regards Roy


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Thu Feb 16, 2017 3:01 pm 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 327
roy wrote:
Hi Gregor

I use the SciTE editor and when you press 'F5' the app you are working on runs on BlueStacks or you device, which ever you are using. But it runs on the official version of BASIC!

I would like to press 'F5' and it run on your version. Also I would like to be able to make an APK with your version.

I sure others would like to do the same.

The last time I asked this question I was pointed the this link:
viewtopic.php?f=4&t=4710&hilit=tools

Unfortunately I didn't get any where with that.

Regards Roy


If you use Quick APK:

How to Swap Basic.apk(Quick APK) with Basic.apk(OliBasicXII)
Go to the "RFO-BASIC! Quick APK" folder
On Windows normally:
C:\Program Files\RFO-BASIC! Quick APK\tools

Rename Basic.apk into Basic2016.07.20.apk
Copy
https://github.com/RFO-BASIC/Basic/files/781389/OliBasicXII.for.Quick.APK.zip
Basic.apk from OliBasicXII for Quick APK.zip
into the "RFO-BASIC! Quick APK" folder



If you use an editor like Notepad++, SciTE etc.,
You can work with the great tool "BASIC! Keywords Generator" from Nicolas.
See https://github.com/RFO-BASIC/Basic/files/781683/oli-keywordsXII.zip

Happy coding
Gregor


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Fri Feb 17, 2017 12:23 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Thanks for that Gregor.

I will have a go

Regards Roy


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Fri Feb 17, 2017 12:29 am 
Offline
User avatar

Joined: Sat Oct 04, 2014 5:45 am
Posts: 642
I confirm it is now working for QuickAPK
It also works on a modified version of RFO2APK that is not released yet 8-)

_________________
Download and tutorial for RFODESIGNER
https://sites.google.com/site/rfodesigner/


Report this post
Top
 Profile  
 
 Post subject: Re: Hot summer of code
Unread postPosted: Fri Feb 17, 2017 11:29 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1336
Hi Emile / Gregor

I have Swap Basic.apk(Quick APK) with Basic.apk(OliBasicXII)

Now just to sort the editor out.

I will look forward to using Emile's RFO2APK with Gregor's Basic

Regards Roy


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 90 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next


Who is online

Users browsing this forum: No registered users and 2 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:  
suspicion-preferred