Submitted by TomL_12953 on Mon, 04/13/2009 - 20:11.
You can do this at the start of the program:
DECLARE STRING a$*10, b$*50
This will set the maximum length of a$ to 10 and b$ to 50
If you try to put more than those limits in, an exception will occur so you can trap it and issue an error message or perform corrective action.
If you just want to chop off a string at a certain number of characters, do this:
INPUT PROMPT "Enter a string: ": a$
PRINT "The first ten characters of a$ are: "; a$(1:10)
END
Learn to program in True BASIC with this popular book featuring sample code and step-by-step instructions that will have you quickly creating your own programs.
Comments
Fixed-Lenngth Strings
You can do this at the start of the program:
DECLARE STRING a$*10, b$*50
This will set the maximum length of a$ to 10 and b$ to 50
If you try to put more than those limits in, an exception will occur so you can trap it and issue an error message or perform corrective action.
If you just want to chop off a string at a certain number of characters, do this:
INPUT PROMPT "Enter a string: ": a$
PRINT "The first ten characters of a$ are: "; a$(1:10)
END