QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The MKI$ function encodes an INTEGER numerical value into a 2-byte ASCII STRING value.

Syntax

result$ = MKI$(integerVariableOrLiteral%)

Description

Example(s)

How MKI$ creates a two byte string integer value to save file space.


SCREEN 12    '_PRINTSTRING requires a graphic screen mode
DO
  COLOR 14: LOCATE 13, 20: INPUT "Enter an Integer from 1 to 32767(0 quits): ", number%
  IF number% < 1 THEN EXIT DO
  CLS
  A$ = CHR$(number% MOD 256)   'first digit(0 to 255)
  B$ = CHR$(number% \ 256)     'second digit(0 to 127)

  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.

See Also