It is currently Sat Apr 29, 2017 10:27 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  [ 21 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Announcement about 1.91
Unread postPosted: Sat Apr 01, 2017 3:49 am 
Offline
User avatar

Joined: Sat Dec 08, 2012 2:14 am
Posts: 1128
Location: From Blighty
This:-

Code:
GOTO repeat1
GOTO repeat2

repeat1:
PRINT "repeat1"
repeat2:
PRINT "repeat2"


Breaks at second repeat label GOTO.

Mog


Attachments:
Screenshot_2017-04-01-11-47-17.png
Screenshot_2017-04-01-11-47-17.png [ 16.47 KiB | Viewed 275 times ]
Report this post
Top
 Profile  
 
 Post subject: Re: Announcement about 1.91
Unread postPosted: Sat Apr 01, 2017 4:15 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5487
Location: Paris, France
Can you guys open a dedicated topic? You're hijacking the missing v01.91 announcement thread.

Nevermind, I'll do it myself, if you're ok I will split the topic in 2 different ones.

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Report this post
Top
 Profile  
 
 Post subject: Re: Label regression in 1.91
Unread postPosted: Sat Apr 01, 2017 10:19 am 
Offline

Joined: Wed Oct 03, 2012 9:53 am
Posts: 2795
Location: Colorado, U.S.
Folks, I am sorry I did not see this sooner. I'm having a really hard time catching up everything I've missed, and new stuff is getting drowned out, so I'm not as responsive as I would like to be.

@bk99, you can't have a label that starts with a keyword. It has to be that way. For history, look here and here.

Here's a recap:

Before your program executes, the preprocessor scans the program looking for labels. It stores pointers to the labels, making GOTO and GOSUB very fast. The preprocessor has to be fast, so it is not smart enough to parse command keywords.

During execution, if you get to your label by GOTO or GOSUB, the label is not parsed - control jumps to the statement after the label. But if the interpreter finishes a statement and moves to the next one, and that one happens to be a label, it gets parsed just like any other command. And if it happens to start with a keyword, it IS just another command, and it gets executed.

This is what Mog's code snippets are demonstrating. There's a difference between jumping to a label (no parsing or execution) and stepping to a label (parsing happens). BASIC! has always been that way, except when I broke it.

In v01.87, I added a lot of speed-ups. One of them (on March 9, 2015) was to make the preprocessor "pre-cache" labels. After that, the interpreter never parsed labels. That causes a problem.

There is a very common mistake that programmers make:
Code:
start:
do stuff
goto start:
It is easy to accidentally put a colon after the goto target. You know the target is a label and you know you have a colon after a label so you put the colon after the label in the goto command.

It turns out that his kind of bug can be very hard to find. They only way I know to keep that from happening is to make sure the interpreter gets a shot at parsing things that look like labels.

So in v01.89, I put back the old behavior, where labels always get parsed (except now they only get parsed once!). The fix was to delete one line of code. Unfortunately, in v01.90 I mistakenly put that line back. So v01.90 was broken. And v01.90 was the "latest version" for almost a full year.

I'm sorry, @bk99, you got caught in a very large hole. We can't have it both ways, and I went with the "parse-once", not the "parse-never". It helps avoid a really nasty bug in BASIC! programs, and it is legacy behavior. In my version of the BASIC! universe, backward-compatibility almost always wins.

The BASIC! Editor has a FORMAT item in the menu. Among other things, FORMAT sets all command keywords to all capital letters. It's not perfect: it can be fooled sometimes, but it's very good. Your
Code:
repeat2:
becomes
Code:
REPEAT2:
For variable names that start with keywords, that's a warning that you might have a problem. With labels, that's always an error.

- Marc


Report this post
Top
 Profile  
 
 Post subject: Re: Label regression in 1.91
Unread postPosted: Sat Apr 01, 2017 10:29 am 
Offline

Joined: Wed Oct 03, 2012 9:53 am
Posts: 2795
Location: Colorado, U.S.
That was post #36002 -- I should have typed faster, or researched less! Missed #36000 by an hour. evolbug got it in what might be the last 'bug post. (Or not, we'll see! 'Bye for now, Dan...)

Nicolas, thank you for splitting this topic. Not that anybody cares about request for an announcement post now that there is one, but nobody would look for an explanation of Label behavior under "Announcement about 1.91"!

Gotta go sing an April Fool's concert for an audience of Alzheimer's patients. No fooling!

- Marc


Report this post
Top
 Profile  
 
 Post subject: Re: Label regression in 1.91
Unread postPosted: Sat Apr 01, 2017 11:03 pm 
Offline

Joined: Tue Dec 02, 2014 12:14 pm
Posts: 28
jMarc wrote:
Here's a recap:
...

Thanks for detailed explanation. I get your logic and I think you are right.
Thank you for the BASIC! !
Good luck.
Thanks Mog for discussion.

Sorry for wasting of your time, guys!


Report this post
Top
 Profile  
 
 Post subject: Re: Label regression in 1.91
Unread postPosted: Sun Apr 02, 2017 2:36 am 
Offline
User avatar

Joined: Sat Dec 08, 2012 2:14 am
Posts: 1128
Location: From Blighty
And yes BASIC! has no return label. OPL (originally a Psion Organiser based language did). You had to do this:-

goto repeat2::

print "Hello"
repeat2::

Isn't BASIC! a daisy? To have after a branch off to a GOTO and no return label where there is no line numbers!

That's the only version of BASIC itself I know of.

Mog


Report this post
Top
 Profile  
 
 Post subject: Re: Label regression in 1.91
Unread postPosted: Sun Apr 02, 2017 3:11 am 
Online

Joined: Tue Dec 04, 2012 10:50 am
Posts: 644
Location: UK
Mog wrote:
And yes BASIC! has no return label. OPL (originally a Psion Organiser based language did). You had to do this:-

goto repeat2::

print "Hello"
repeat2::

Isn't BASIC! a daisy? To have after a branch off to a GOTO and no return label where there is no line numbers!

That's the only version of BASIC itself I know of.

Mog

According to my handy OPL programming manual, you don't put any colons on a goto, just like Basic!

You did mean to miss out your "Hello", didn't you?

(For my Psion stuff you could visit: http://www.mjcoon.plus.com/page3.htm)

Mike.


Report this post
Top
 Profile  
 
 Post subject: Re: Label regression in 1.91
Unread postPosted: Sun Apr 02, 2017 4:18 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 818
Location: France
Sorry dear Mike but Mog is right :) :) ;)

According to my handy OPL programming practice... :) :) ;) ExcePsion

Cheers

Gilles

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Report this post
Top
 Profile  
 
 Post subject: Re: Label regression in 1.91
Unread postPosted: Sun Apr 02, 2017 4:57 am 
Online

Joined: Tue Dec 04, 2012 10:50 am
Posts: 644
Location: UK
Cassiope34 wrote:
Sorry dear Mike but Mog is right :) :) ;)

According to my handy OPL programming practice... :) :) ;) ExcePsion

My French is not up to reading that page (except the English bits!). You'll have to give me a better pointer. A search for "::" did not find anything...

I only have a Series-3 manual, but I did port some of my freeware to Series-5 with the help of a porting guide.

Mike.


Report this post
Top
 Profile  
 
 Post subject: Re: Label regression in 1.91
Unread postPosted: Sun Apr 02, 2017 7:45 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 818
Location: France
Yes ! sorry Mike, but you can believe me when I say that Mog is right :)

I wrote so much code in OPL :)

In OPL only labels needed ::

but there it were mostly pocedures started by the word PROC name: and ended by the word ENDP that can be use as Functions if you add it parameters between parentheses ...

and a procedure is generally called by it's name followed by ":"

What was good was that the names of the procedures can be treated as a string variable... with @ in front (see PROC debut:)

Cheers

Gilles

PS: sorry Mike : I did not often use Labels and its GOTO so there is none in the example below :) ;)

Code:
global touche%(9),coup%,best%,position%,nb,id%
rem ----------------------------
rem  On démarre les nombres pseudo aléatoires
rem ----------------------------
RANDOMIZE MINUTE + SECOND
rem ----------------------------
rem      action des touches
rem ----------------------------
nb%=0
touche%(1)=27
touche%(2)=7
touche%(3)=54
touche%(4)=73
touche%(5)=186
touche%(6)=292
touche%(7)=216
touche%(8)=448
touche%(9)=432
debut:
endp

proc jeu:
local k&
id%=gcreate(50,10,150,145,1,$412)
guse id%
nb%=nb%+1
alea:
affiche:
rem ----------------------------
rem      Gestion du pointeur
rem ----------------------------
do
getevent32 a&()
k&=a&(1)
if k&=KEvPtr& AND a&(KEvAPtrType%)=KEvPtrPenUp&
    xptr%=a&(KEvAPtrScreenPosX%)
    yptr%=a&(KEvAPtrScreenPosY%)
    rang%=0
    rem ----------------------------
    rem  A-t-on cliquer sur la grille ?
    rem ----------------------------
    if xptr%>50 AND xptr%<200 AND yptr%>10 AND yptr%<160
      rang%=1+3*INT((yptr%-10)/50)+INT((xptr%-50)/50)
    endif
    rem ----------------------------
    rem  Si OUI alors nouvelle position
    rem ----------------------------
    if rang%>0 AND rang%<10
     coup%=coup%+1
     best%=XOR%:(best%,2**rang%)
     position%=XOR%:(position%,touche%(rang%))
     affiche:
    endif
endif
until k&=10000 OR position%=495
rem ----------------------------
rem  Le joueur a-t-il gagné ?
rem ----------------------------
if position%=495
   affscore:
   gclose id%
endif
endp

rem ----------------------------
rem  La fonction XOR
rem ----------------------------

proc XOR%:(a%,b%)
return (a% AND NOT b%) OR (NOT a% AND b%)
endp

rem ----------------------------
rem  Choix position de départ
rem ----------------------------

proc alea:
coup%=0
best%=0
position%=INT(RND*512)
endp

proc affiche:
local i%,j%,x%,y%
j%=1
i%=1
gcls
rem ----------------------------
rem  On cherche les 1 dans position
rem  et on affiche alors une figure
rem ----------------------------
  do
  if (j% AND position%)>0
   x%=15+50*modulo%:(i%-1,3)
   y%=15+50*INT((i%-1)/3)
   gAT x%,y%
   gcircle 10,1
  endif
  j%=2*j%
  i%=i%+1
until i%=10
endp

rem ----------------------------
rem  La fonction MODULO
rem ----------------------------

proc modulo%:(a%,b%)
return a%-b%*INT(a%/b%)
endp

proc affscore:
local i%,id%,jd%
jd%=gcreate(300,40,60,30,1)
guse jd%
gat 1,20
gprint "SCORE"
id%=gcreate(300,80,60,30,1,$412)
guse id%
nb=0
i%=1
rem ----------------------------
rem  On recherche la meilleure stratégie
rem ----------------------------
do
  if (best% AND 2**i%)<>0
   nb=nb+1
  endif
  i%=i%+1
until i%=10
nb=INT(100*nb/coup%)
gat 20,20
gprint nb
get
gclose id%
gclose jd%
debut:
endp

rem ----------------------------
rem  Affichage du menu
rem ----------------------------

proc procq:
stop
endp

proc procn:
  if nb%>0
   gclose id%
  endif
  jeu:
endp

proc proca:
local i%
dINIT "A propos de MORPION"
dPOSITION 1,1
dTEXT "","Version 1.1",2
dTEXT "","schraf.professeur.org",2
i%=DIALOG
debut:
endp

proc proch:
local i%
dINIT "Aide"
dTEXT "","Le but est d'afficher"
dTEXT "","toutes les citrouilles"
dTEXT "","sauf celle du milieu."
i%=DIALOG
debut:
endp

proc debut:
local k%,choix$(4),a$(5)
choix$="nqah"
do
mINIT
mCARD "JEU","Nouveau",-%n,"Quitter",%q
mCARD "?","Aide",%h,"A propos...",%a
k%=MENU
  if k% AND (LOC(choix$,CHR$(k%))<>0)
  a$="proc"+CHR$(k%)
  @(a$):
  endif
until 0
endp

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


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


Who is online

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