Strings: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement - "Building Blocks Categories" to "Building Blocks") |
m (1 revision imported) |
Latest revision as of 03:04, 11 October 2023
Description
- Strings are representations of alphanumeric characters and are always enclosed in double quotes ("). No quotation marks are allowed within a string.
- A string can contain digits 0 thru 9, but they are character representations of the numbers and cannot be used as numbers. To convert a string of digits to its numeric equivalent, use the VAL() function.
Syntax
- A string literal:
- "Hello World"
- "a = 1 + 3 * x" - (Produces: a = 1 + 3 * x)
- A string variable:
- myString$ = "Hello World"
Hints
- Manipulating Strings. There are only two ways in JB to represent literal or variable values: string values or numeric values. Strings are, in effect, just text. Numeric values can be manipulated with mathematical operators. String values also can be manipulated, but in different ways. Strings can be added together; that's called concatenation. You can extract from strings using the string functions LEFT$(), MID$(), and RIGHT$(). You cannot divide a string by another string or multiply a string by another string.
- Concatenation.You can add together string literals or string variables, or combinations of both, using the plus (+) sign:
three$ = "and a three..." print "A one... " + " and a two..." + three$
- You can also use the semi-colon (;) to add strings together:
three$ = "and a three..." print "A one... " ; " and a two..." ; three$
- You get an additional capability when using the semi-colon; you can add numeric values (literal, variables, or expressions) into your concatenated string:
print "A one... " ; " and a two..." ; " and a " ; 3
- Empty Strings. It is allowable to have only quotation marks with nothing between - "" -. This is called an empty string. It can be used to display a blank line, for instance.
- Printing Double Quotation Marks. If it is necessary to include quotation marks within your string, you can use the CHR$() function with the ASCII value which represents a double quote (34) and concatenate your string, like this:
print "A one... " ; " and a "; chr$(34); "two..." ; chr$(34) ; " and a " ; 3
Example
' Place a simple, working example of the keyword here
Useful Procedures
' Place a useful function or sub using this keyword here