LB Booster
« LEN function different in LBB and LB »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:19am



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: LEN function different in LBB and LB  (Read 246 times)
Argand
New Member
Image


member is offline

Avatar




PM


Posts: 1
xx LEN function different in LBB and LB
« Thread started on: Feb 15th, 2017, 10:24pm »

I notice that the LEN function in LBB is different to LB. For example the code for the string " x ", i.e. (two spaces,x,two spaces) below

PROMPT "type a string:"; string$
TotalLength = LEN(string$)
PRINT "The total number of characters in your string is :" ;
PRINT TotalLength
END

gives 5 in LBB but gives 1 in LB. So LBB counts spaces as well as letters and numbers.
User IP Logged

CirothUngol
New Member
Image


member is offline

Avatar

Odie, Odie, cha cha cha.


PM

Gender: Male
Posts: 44
xx Re: LEN function different in LBB and LB
« Reply #1 on: Feb 16th, 2017, 01:51am »

It's not the LEN() function, it's the PROMPT command. Try the following Code:
PROMPT "type a string:"; string$
string2$ = "  x  "
TotalLength = LEN(string$)
OtherLength = LEN(string2$)
PRINT "The total number of characters in your string is :" ; TotalLength
PRINT "The total number of characters in the other string is :" ; OtherLength
END 
Apparently, LB does an automatic TRIM$() to remove any leading or trialing white space from PROMPT. I would be more inclined to consider it an error in LB, to be honest. I'll TRIM$() my own input, thank you. ^_^
User IP Logged

LB Booster + LB Workshop + LB Builder = My Programs on Google Drive
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LEN function different in LBB and LB
« Reply #2 on: Feb 16th, 2017, 09:56am »

on Feb 16th, 2017, 01:51am, CirothUngol wrote:
Apparently, LB does an automatic TRIM$() to remove any leading or trialing white space from PROMPT.

Interesting. I've never noticed it, no doubt because typing leading and/or trailing spaces in response to a PROMPT isn't particularly 'natural'. LBB could easily be changed of course, but it would reduce flexibility and as you say adding an explicit TRIM$() in your program is straightforward.

So I'm inclined to leave it as it is, but something to be borne in mind.

Richard.
User IP Logged

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