MID$ (function)

Syntax: mid$(text$, start[, length])
Type: function

returns a section of a string starting from 'start' for 'length' characters. If 'length' is not used then all of the characters until the end of the string are used.
MID$ with len = 0 should return an empty string (v1c)

e.g.

print mid$("abcdefg", 3, 2) 'returns "cd"
print mid$("abcdefg", 3) 'returns "cdefg"
print mid$("abcdefg", 2, 1) 'returns "b"

See also instr, mid$ (statement).

MID$ (statement)

Syntax: mid$(text$, start[, length]) = value$
Type: statement

Allows part of a string to be replaced.

e.g.

text$ = "abc 123"
print text$ 'returns "abc 123"
mid$(text$, 5, 3) = "456"
print text$ 'returns "abc 456"

See also mid$ (function).

MKD$

Syntax: mkd$(number as double)
Type: function

Encodes a double-precision floating point number to a string. Useful with field.

small example on syntax:


dim n as double
n = 1.2345
e$ = mkd$(n)

See also mki$, mkl$, mks$, CVD, CVI, CVL, CVS.

MKDIR

Syntax: mkdir folder$
Type: statement
Category: File

Makes a folder on the local file system.

e.g.

mkdir "data"

makes a folder called 'data' in the current folder.

See also shell, rmdir.

MKI$

Type: function

Encodes a 32bit integer number to a string. Useful with field.

small example on syntax:


dim n as integer
n = 43
e$ = mki$(n)



See also mkd$, mkl$, mks$, CVD, CVI, CVL, CVS.

MKL$

Type: function

Encodes a long number to a string. Useful with field. Since long's in FB are the same as Integers, this is the same as MKI$.

small example on syntax:


dim n as long
n = 31
e$ = mkl$(n)



See also mkd$, mki$, mks$, CVD, CVI, CVL, CVS.

MKS$

Type: function

Encodes a single-precision floating point number to a string. Useful with field.

small example on syntax:


dim n as single
n = 1.2345
e$ = mks$(n)



See also mkd$, mki$, mkl$, CVD, CVI, CVL, CVS.

MOD

Syntax: a mod b
Category: math

Returns the remainder of a divided by b (modulus).

e.g.

print 10 mod 4 'returns "2"

multikey

Syntax: multikey(scancode)
Type: function
Category: Gfx

Function to detect multiple keypresses.

'scancode' is the DOS hardware scancode of the key you want to query for.

This function lets you detect the immediate status of any key at any time; the returned value is -1 if key is pressed, 0 otherwise. The keyboard input buffer is not disabled while you use MULTIKEY; that is, pressed keys will be stored and subsequently returned by your next call to INKEY$. This means you have to empty INKEY$ when you finish using MULTIKEY:

WHILE INKEY$ <> "": WEND



Keeping INKEY$ to work while you use MULTIKEY allows more flexibility and can be useful to detect CHR$(255)+"X" combo returned on window close button click. Pay attention: this function does only work if you are in gfx mode; it does NOT work in console mode. For a list of accepted scancodes, see DOS keyboard scancodes.


Example:


DIM work_page AS INTEGER, x AS INTEGER, y AS INTEGER
' Request 640x480 with 2 pages
SCREEN 18, ,2
COLOR 2, 15
work_page = 0
x = 320
y = 240
DO
' Let's work on a page while we display the other one
SCREENSET work_page, work_page XOR 1
' Check arrow keys and update position accordingly
IF MULTIKEY(&h4B) AND x > 0 THEN x = x - 1
IF MULTIKEY(&h4D) AND x < 639 THEN x = x + 1
IF MULTIKEY(&h48) AND y > 0 THEN y = y - 1
IF MULTIKEY(&h50) AND y < 479 THEN y = y + 1
CLS
CIRCLE(x, y), 30, , , , ,F
' Page flip
work_page = work_page XOR 1
LOOP WHILE NOT MULTIKEY(&h1)
' Clear input buffer
WHILE INKEY$ <> "": WEND
' Restore both work and visible pages to page 0
SCREENSET
PRINT "Press any key to exit..."
SLEEP



See also screen (graphics), INKEY$.

Differences:
New to FreeBasic