SWAP
SWAP a, b
Exchanges the values of the two variables a
and
b
. a
and b
may be variables of
any type.
Example 1: Swap numbers
1
a = 2
b =
print "Before: "; a, b ' Output: Before: 1 2
swap a,b
print "After: "; a, b ' Output: Before: 2 1
Example 2: Swap strings
"abc"
s1 = "xyz"
s2 =
print "Before: "; s1, s2 ' Output: Before: abc xyz
swap s1, s2
print "After: "; s1, s2 ' Output: After: xyz abc
Example 3: Swap arrays
1,2,3]
A = [7,8,9]
B = [
print "Before: "; A, B ' Output: Before: [1,2,3] [7,8,9]
swap A, B
print "After: "; A, B ' Output: After: [7,8,9] [1,2,3]
Code samples using SWAP
100lines.bas
betrayal: crows ii.bas
btn 21.bas
leastq.bas
memory match game.bas
mousef.bas
nim.bas
no window setup.bas
pirate.bas
rogue trader.bas
screen saver number 1.bas
screensaveandload.bas
screensv_ld_compres.bas
siepinsky forest.bas
slide sq w mouse.bas
sliding blocks puzzle.bas
sliding blocks.bas
star worlds.bas
Data
APPEND
ARRAY
DATA
DELETE
DIM
EMPTY
ERASE
INSERT
ISARRAY
ISDIR
ISFILE
ISLINK
ISMAP
ISNUMBER
ISSTRING
LBOUND
LEN
READ
REDIM
RESTORE
SEARCH
SORT
SWAP
UBOUND
If there is insufficient information on this page and you wish learn more about SWAP,
please send an email to smallbasic@gmail.com. You can help to improve information about
SWAP by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.