Truncating Strings

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators: Administrator, Global Moderator

Post Reply
Guest

Truncating Strings

Post by Guest »

What is the command to resize a string?  Example:

I want to resize "electric guitar" to just "electric"

(AKA removing the last eight characters)

Are there any commands to do this?
madmartin55
Newbie
Posts: 8
Joined: Tue Jun 18, 2002 12:25 am
Contact:

Re: Truncating Strings

Post by madmartin55 »

Try:

a$=LEFT$(a$, 8 )

:)
stuck in a time warp

"Let's do the time warp again!"
Guest

Re: Truncating Strings

Post by Guest »

If you want to seperate it based on spaces try:

L=LEN(A$)
FOR A=1 TO L
B$=MID$(L,A$,1)
IF B$=" " THEN GOTO 10
NEXT

10 C$=LEFT$(A$,L)

That's from memory, so you probably should check the help file for MID$ cuz I don't remember which (L A$ or 1) goes where, but L is the position, A$ is the string, and 1 is the length.
Post Reply