out of memory problems working in basic (Development MSX Fora)MSX Resource Center PassionMSX MSX2 contest           
            
English Nederlands Español Português Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 134 gasten en 4 MSX vrienden online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - out of memory problems working in basic

Ga naar pagina ( Vorige pagina 1 | 2 )
Schrijver

out of memory problems working in basic

MrRudi
msx addict
Berichten: 465
Geplaatst: 09 Februari 2005, 01:50   
Quote:



and this question for the MSXBASIC geeks......

when i programmed in BASIC, i have the need to exit the bucle FOR/NEXT conditionaly BY example:

FOR I=10 to 1 step -1
if STRIG(pl) then 2000
NEXT I

now the question, this will increase the FOR/NEXT stack?



Yes it will...do that a couple of time and your MSX will hang up unless of course you do "I = 1:return" somewhere in the subroutine starting at 2000

AuroraMSX

msx master
Berichten: 1228
Geplaatst: 09 Februari 2005, 10:52   
Quote:

and this question for the MSXBASIC geeks......

when i programmed in BASIC, i have the need to exit the bucle FOR/NEXT conditionaly BY example:

FOR I=10 to 1 step -1
if STRIG(pl) then 2000
NEXT I

now the question, this will increase the FOR/NEXT stack?

exists a safe way to exit from a bucle like that without increasing the FOR/NEXT stack?



Bad solution - before jumping out, set I to the max value and do NEXT:
100 FOR I=1 to 10
110 IF STRIG(0) THEN I=10: NEXT I: GOTO 200
120 NEXT I
130 END
200 ' Do the do


Better solution - avoid FOR/NEXT in this case:
100 I=1
110 IF STRIG(0) GOTO 200
120 I=I+1: IF I<11 GOTO 110
130 END
200 ' Do the dobedeedo

AuroraMSX

msx master
Berichten: 1228
Geplaatst: 09 Februari 2005, 10:55   
BTW: It's called a "loop", not a "bucle"
wolf_
online

msx legend
Berichten: 4658
Geplaatst: 09 Februari 2005, 11:02   
bucle could be a perfect typo of cycle when looking at the location of the keys
Grauw
msx professional
Berichten: 1002
Geplaatst: 09 Februari 2005, 22:51   
Quote:

and this question for the MSXBASIC geeks......

when i programmed in BASIC, i have the need to exit the bucle FOR/NEXT conditionaly BY example:

FOR I=10 to 1 step -1
if STRIG(pl) then 2000
NEXT I

now the question, this will increase the FOR/NEXT stack?


The solution is to do a NEXT which ends the loop before the GOTO... Change:

IF STRIG(pl) THEN GOTO 2000

--> into -->

IF STRIG(pl) THEN I=1 : NEXT : GOTO 2000

Of course, you can set I to any value beyond the FOR’s range, e.g. 0, -1 or -999 would do as well in this case.

(sidenote: in the case of IF STRIG(pl) THEN 2000, if you change it into IF STRIG(pl) GOTO 2000 it will do the same, but will be slightly faster!)


~Grauw
Grauw
msx professional
Berichten: 1002
Geplaatst: 09 Februari 2005, 23:29   
Ack, Aurora already posted this solution -_-;;...

I wouldn’t call it a ‘bad’ solution though, you’re using a loop for a loop, and that’s perfectly alright. Breaking out of a loop is common practice in many other languages (break in C-style languages), and it is perfectly acceptable...


~Grauw
AuroraMSX

msx master
Berichten: 1228
Geplaatst: 10 Februari 2005, 10:27   
Quote:

Ack, Aurora already posted this solution -_-;;...



And D-Tail is getting the credit for it on your BASIC tips page (map.tni.nl/articles/basic_tips_tricks.php)!

Quote:

Breaking out of a loop is common practice in many other languages (break in C-style languages), and it is perfectly acceptable...



The difference is that C provides a means (break) to break out of the loop. In MSX-BASIC you're using a trick. That's what makes it a less attractive solution, in my view.

[edit]How does that b****y URL BBtag work, dammit?[/edit]
snout

msx legend
Berichten: 4991
Geplaatst: 10 Februari 2005, 10:31   
[url=http://www.msx.org/]MSX Resource Center[/url]

AuroraMSX

msx master
Berichten: 1228
Geplaatst: 10 Februari 2005, 11:12   
Quote:

[url=http://www.msx.org/]MSX Resource Center[/url]



Thanx Would it be possible to have exactly that text as hint below the message edit box, in the section that explains the BBCode tags?
 
Ga naar pagina ( Vorige pagina 1 | 2 )
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.