Greetings Daniel,
I have a quick one for you this time.
I want to strip the first and last character from a string.
What is the most efficient way to do this in BASIC?
Thanks for your help Daniel.
Robert
.
How-to strip the first & last character from a string ???
-
RBSe
- Posts: 33
- Joined: Thu Mar 07, 2013 2:42 am
- Yahoo Messenger: RBSe@yahoo.com
- Location: Eureka, California
How-to strip the first & last character from a string ???
Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom.
Clifford Stoll
Clifford Stoll
-
Daniel
- Posts: 133
- Joined: Tue Nov 13, 2012 9:10 pm
Re: How-to strip the first & last character from a string ??
Hi Robert
The easiest way is with the LEFT$, RIGHT$ and LEN functions. Lets call the string A$
If you run this program it will print
Hope this is clear. There is also a MID$ function for breaking strings in pieces.
Daniel
The easiest way is with the LEFT$, RIGHT$ and LEN functions. Lets call the string A$
Code: Select all
A$="abcdefghijklmnopqrstuvwxyz"
LenA = LEN( A$)
PRINT LenA
'Remove right most character
ShortA$ = LEFT$( A$, LenA-1)
PRINT ShortA$
EvenShorterA$= RIGHT$( ShortA$, LenA-2)
PRINT EvenShorterA$
END
Code: Select all
26
abcdefghijklmnopqrstuvwxy
bcdefghijklmnopqrstuvwxy
Daniel
-
RBSe
- Posts: 33
- Joined: Thu Mar 07, 2013 2:42 am
- Yahoo Messenger: RBSe@yahoo.com
- Location: Eureka, California
Re: How-to strip the first & last character from a string ??
Thanks Daniel,
That makes it clear and easy to understand...
Robert
.
That makes it clear and easy to understand...
Robert
.
Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom.
Clifford Stoll
Clifford Stoll