MKI$ - mkilgore/QB64pe GitHub Wiki
The MKI$ function encodes an INTEGER numerical value into a 2-byte ASCII STRING value.
- result$ = MKI$(integerVariableOrLiteral%)
- integerVariableOrLiteral% is converted to two ASCII characters.
- INTEGER values can range from -32768 to 32767.
- MKI$ string values can be converted back to numerical INTEGER values using CVI.
- The function takes up less byte space in a file than using the text numerical value when the value is over 2 digits.
- When a variable value is used with PUT a numerical value is converted automatically in RANDOM and BINARY files.
Example: How MKI$ creates a two byte string integer value to save file space.
MKIvalue$ = A$ + B$ Q$ = CHR$(34) strng$ = "CHR$(" + LTRIM$(STR$(number% MOD 256)) + ") + CHR$(" + LTRIM$(STR$(number% \ 256)) + ")" COLOR 11 _PRINTSTRING (222, 252), STR$(number%) + " = " + strng$ _PRINTSTRING (252, 300), "MKI$ value = " + Q$ + MKIvalue$ + Q$ 'print ASCII characters LOOP END '' '' |
- Explanation: INPUT in QB64 limits integer entries to 32767 maximum. MOD 256 finds the part of a value from 0 to 255 while the second value is the number of times that 256 can go into the value. _PRINTSTRING can print all of the ASCII characters.
Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page