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 ???
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
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
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