Jump to content
  • 0

For...Next


BRDB_82
 Share

Question

Hi all,

Firstly I'll give the code:

Quote

101 BLOCKS=24576
102 FOR FLN=0 TO BLOCKS
103 FLNN$=STR$(FLN):FLNLL=LEN(FLNN$):FLNN$=RIGHT$(FLNN$,FLNLL-1)
104 PRINT FLN;FLNN$
105 NEXT

So, what do I expect from this; for starters, that FLN  increments until it reaches BLOCKS.
I convert the FLN to string, by using STR$ and removing the space on the left, as I need to combine it with another string. But since it goes wrong here, it has to avail to continue the code.
When I run the program it states by 104 that FLN stays 2, and FLNN$ stays 3.

When I run the same code in QB64, it works flawlessly, so I'm not really sure on what I'm doing wrong here.  Perhaps someone can try this and shed some light?

 

  • Like 1
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
Hi all,

Firstly I'll give the code:

101 BLOCKS=24576

102 FOR FLN=0 TO BLOCKS

103 FLNN$=STR$(FLN):FLNLL=LEN(FLNN$):FLNN$=RIGHT$(FLNN$,FLNLL-1)

104 PRINT FLN;FLNN$

105 NEXT

So, what do I expect from this; for starters, that FLN  increments until it reaches BLOCKS.

I convert the FLN to string, by using STR$ and removing the space on the left, as I need to combine it with another string. But since it goes wrong here, it has to avail to continue the code.

When I run the program it states by 104 that FLN stays 2, and FLNN$ stays 3.

 

When I run the same code in QB64, it works flawlessly, so I'm not really sure on what I'm doing wrong here.  Perhaps someone can try this and shed some light?

 

 

Basic tokenizes variable names which means everything after the first two characters is treated as the same.

 

This means in your code FLN, FLNLL are actually the same variable. Give them more unique names and the behavior should be corrected. It’s a BASIC V2 limitation.

 

 

Sent from my iPhone using Tapatalk

  • Like 2
Link to comment
Share on other sites

  • 0

Lorin Millsap, thanks for insight in this. I've been able to change the code and it works. I even took the liberty to create an excel sheet with AA to ZZ so I can mark which I've used so far (or can't use like IF and FN 😉 )

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use