-
-
Notifications
You must be signed in to change notification settings - Fork 2
Strings
In ICE, you can store a string into any of the 10 string vars (Str0 through Str9) using the standard syntax: "THIS IS A STRING"→Str1
. You also have the length(
, sub(
, and +
commands that work similarly to how they would in TI-BASIC:
length(
returns the length, in characters, of the string you give it: length("ALPHABET")
returns 8, "SOMETHING"→Str1:length(Str1)
returns 9.
sub(
cuts out part of a string, puts it into temporary memory, and returns a pointer to it. Proper usage would be: sub(STRING,OFFSET,SIZE)
. With STRING
being either a string variable (Str0-Str9) or a string on it's own ("EXAMPLE"), OFFSET
being the amount of characters to skip before beginning the cut, and SIZE
being the length of the cut, in characters, starting from the offset. (If you wish to start cutting from the beginning of a string, you may use 0 as an offset). With the pointer, you can read the temporary memory and put it back into a string. Remember that all strings in memory are null-terminated (simply meaning that their end is signified by a 0 byte).
+
concatenates two strings:
Concatenation | Result |
---|---|
"SOME"+"BODY"→Str1 |
Str1 would then be "SOMEBODY". |
"BODY"+"SOME"→Str3 |
Str3 would then be "BODYSOME". |
Str1+" ONCE TOLD ME"→Str0 |
Str0 would then be "SOMEBODY ONCE TOLD ME". |
Besides using the standard syntax of "STUFF"→Str1
, you can also place a string (text in quotes) at a part of your program, and it will be compiled into your program's code with its pointer returned. For example, when ICE reads "PINEAPPLE"→A
, the binary data for "PINEAPPLE" will be compiled into your final program and its pointer will be stored into A
. With this, you can later use Copy(
commands to read from strings stored in your program code. If you place a string token on its own, without storing anything to it, it will return the memory address of the string. You can use this in commands that require a pointer to a string or for other purposes. The only exception for this is when using a string in a Disp
command.
Note: each string variable has a total size limit of 2000 bytes.
ICE Compiler | Peter Tillema
- Introduction
- Building your first program
- Math and numbers
- Variables
- Standard system commands
- Program flow control
- Pointers
- Graphics
- Sprites
- Tilemaps
- Useful routines