By using [], you can get one character in the string or replace the character at the specified position.
A$="12345" A$[3] → "4" A$[3]="ABC" → "123ABC5"
A string with the first character you want to check
The character code of the specified character
A=ASC("A") X=ASC("XYZ")
・It can be used in constant expressions.
Character code of the character you want to get
One string corresponding to the character code
S$=CHR$(65)
String representing a number ("123" etc.)
Numeric value interpreted from character string
A=VAL("123") F=VAL("-12.56")
The number you want to convert to a string
Specified when you want to right align with the specified number of digits: 0 to 63
・If the number of digits of the numerical value is larger than the specified number of digits, the specification is ignored.
・When 0 is specified, no alignment is performed.
・0, if not specified.
Converted string (123 → "123")
S$=STR$(123)
Numerica value to be converted to hexadecimal string
・If a Real is specified, the decimal part is rounded toward zero.
Number of degits with a hexadecimal character string to be output: 0 to 8
・If a value of 1 or more is specified, a string with placing 0 at the beginning is returned.
・When 0 is specified, 0 is not placed at the beginning.
・0, if not specified.
Conversion result hexadecimal string
S$=HEX$(65535,4)
Numeric value to convert to a binary string
・If a Real is specified, the decimal part is rounded toward zero.
Number of digits with the a binary string to be output: 0 to 32
・If a value of 1 or more is specified, a string with placing 0 at the beginning is returned.
・When 0 is specified, 0 is not placed at the beginning.
・0, if not specified.
Conversion result binary string
S$=BIN$(65535,16)
A string to be formatted and embedded
・Control the value formatting method by adding the following type specification or auxiliary specification after %.
%S | Outputs the contents of a string variable |
%D | Decimal Int Output |
%X | Hexadecimal Int Output |
%F | Real Output |
%B | Binary Int Output |
%% | Output the Character % |
Format the output by specifying the following auxiliary specification after %
・Number of digits specification: Specify the number of digits (%8D,%4X)
・Specify the number of decimal places: The total number of digits, the number of digits in the decimal part (%8.2F)
・Blank padding: Specify a space character + number of digits (% 4D → " 0")
・Zero padding: Specify 0 + number of digits (%08D → "00000000")
・Left alignment: Specify -symbol + number of digits (%-8D)
・+Sign display: Specify +symbol + number of digits (%+8D)
・Specify the value to be formatted and converted into a string as many arguments as the % specified in the format string (excluding %%).
・An error occurs if the % specification does not match with the type expected and the argument type.
Generated string
S$=FORMAT$("%06D",A)
A number of characters in a string you want to check
A number of elements in an array you want to check
・For String: A number of characters
・For Array: A number of elements
? LEN("ABC123") DIM B[4] ? LEN(B)
String or array to check for the end
Subscript number at the end
・For both strings and arrays, return the value obtained by subtracting 1 from the return value of the LEN function.
DIM X[10] FOR I=0 TO LAST(X) X[I]=I NEXT
Target string
Start position of the acquired string
Number of characters in the acquired string
・If not specified, the number of characters from the start position to the end of the string is specified.
Obtained string
S$=MID$("ABC",0,2)
Target string
Number of characters in the acquired string
Obtained string
S$=LEFT$("ABC",2)
Target string
Number of characters in the acquired string
Obtained string
S$=RIGHT$("ABC",2)
The position within the string to start the search
・If not specified, search from the beginning of the string.
Search target string
The string to search for
Found: Position in the string
Not found: -1
A=INSTR(0,"ABC","B")
Replace target string
Replacement start position
Number of characters to be replaced
・If not specified, all characters after the start position are replaced with the replacement string.
Replace this string with the number of characters from the start position
Replaced string
A$=SUBST$("ABC",0,2,"XY")
Current date string
・The format is "Year/Month/Day".
Current time string
・The format is "Hour:Minute:Second".