LB Booster
« Printing array issue »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:47am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Printing array issue  (Read 163 times)
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx Printing array issue
« Thread started on: Sep 30th, 2017, 12:08pm »

Hi,

I'm stuck in something obviously simple...but I can't see the mote in my eye.

Code:
Counter = 0
L1$ = "AAA"     : L1 = LEN(L1$)
L2$ = "BBBBB"   : L2 = LEN(L2$)
L3$ = "CCCCCCC" : L3 = LEN(L3$)
FOR Counter = 1 TO 3
    PRINT Counter, L(Counter)
NEXT Counter 


How do I make L(Counter) show up correctly in the list instead of "0"?
User IP Logged

Roger
Rod
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 110
xx Re: Printing array issue
« Reply #1 on: Sep 30th, 2017, 2:53pm »

Code:
Counter = 0 '? Counter is set to 1 when you enter the for next loop
dim L(3) 'create the array you intend to use
'store the length to this array, not L1,L2,L3
L1$ = "AAA"     : L(1) = LEN(L1$)
L2$ = "BBBBB"   : L(2) = LEN(L2$)
L3$ = "CCCCCCC" : L(3) = LEN(L3$)
FOR Counter = 1 TO 3
    PRINT Counter, L(Counter)
NEXT Counter
 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Printing array issue
« Reply #2 on: Sep 30th, 2017, 3:10pm »

on Sep 30th, 2017, 12:08pm, flotulopex wrote:
How do I make L(Counter) show up correctly in the list instead of "0"?

Another way:

Code:
Counter = 0
L1$ = "AAA"     : L1 = LEN(L1$)
L2$ = "BBBBB"   : L2 = LEN(L2$)
L3$ = "CCCCCCC" : L3 = LEN(L3$)
FOR Counter = 1 TO 3
    PRINT Counter, EVAL("L";Counter)
NEXT Counter 

Fewer changes from the original than Rod's solution, but using EVAL like this isn't recommended.

Richard.
« Last Edit: Sep 30th, 2017, 3:11pm by Richard Russell » User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx Re: Printing array issue
« Reply #3 on: Oct 1st, 2017, 08:45am »

Thanks a lot guys wink
User IP Logged

Roger
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls