HOME >> Tutorials >> Strings

Strings

Hey! I'm assuming that since you're reading this, you want to learn about strings. Not only can you store names and words to them, you can use them to store data into. In order to be able to use strings to there fullest extent, you will need to learn all the commands and tricks that make strings so powerful.

Here is a list of the different commands you should learn that are used with strings.

+ Equ>String(
expr(
InString(
Length(
String>Equ(
Sub(

Now I know all these commands are in your book but sometimes it's hard to understand something you aren't familiar with. That's why I'm here.

All code is underlined

Using the "+": You can use + with strings to combine two strings together.

Ex.
"I LIKESTOREStr1
"STRINGSSTOREStr2
Str1+"_"+Str2STOREStr3

String 3 would then be "I LIKE STINGS" you can figure that one out I think.

Equ>String: Even though I rarely use this command, Equ>String( can be very useful. You can use it to store Y1 or any of those variables to strings. String>Equ does just the opposite of that.

Expr: Expr( is a VERY useful command. You can use it to convert strings into an expression.

Ex.
"12345STOREStr1
expr(Str1STOREA

That would store 12345 to a sting; you can combine commands and only select a part to use. I use this to test strings that I stored data to. I'll touch on that more later.

InString: The InString( command can be used to tell you where in a string a certain group of characters is.

Ex.
"MADE IN THE USASTOREStr1
InString(Str1,"USA

That would give you 13 because it begins at the 13th character. You can use this in tests and any other things you can think of.

Length: You can use length( to test how many characters are in a certain string. You can store this to a variable for later use in your programs.

Ex.
"STRINGSSTOREStr1
length(Str1STOREA

"A" would be 7. Remember that you can use most of these commands in If statements.

Sub: Now probably the best command for strings is sub(. This command is used for selecting certain portions of a string. You can store the answer of this command to other strings. You can also combine this with expr( to test for a number at a certain part in the string. The first part after the command you put is the string your checking, the second is where to start, and the third is how many after the start.

Ex.
"STAIND234STOREStr1
sub(str1,1,6STOREStr2
expr(sub(Str1,7,3)STOREA

String 2 is STAIND and A would be 234. I use this command in level loading programs too. I just test the certain part of the string for a number and output the picture accordingly.

Ex. "1111110101101011000111111STOREStr1
1STOREX:1STOREY:1STOREA
ClrHome
Repeat X=26
expr(sub(str1,A,1))STOREStr2
If B=1:Output(X,Y,"H
A+1STOREA
Y+1STOREY
If Y=6
Then
1STOREY
X+1STOREX
End
End

There that's kind of how my loading programs are. You can also use letters but then you can't use the expr( command. If you did you would just change B to Str2, get rid of the expr( command and, say If Str2="A" or whatever letter you use. And you can make it better by adding more outputs to make you game look even better. You can then make a walk around program and make a maze or something. Be creative and don't limit yourself.

Try combining these commands because you can really make some nice programs if you know how to really use all these commands. I hoped I helped a lot. Later!

By: Sean Sartell





Problems with this page?
Contact the Webmaster.