GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | SWAP

Edit History

SWAP

SWAP a, b

Home > Reference > Data

Exchanges the values of the two variables a and b. a and b may be variables of any type.

Example 1: Swap numbers

a = 1
b = 2

print "Before: "; a, b      ' Output: Before: 1   2
swap a,b
print "After:  "; a, b      ' Output: Before: 2   1

Example 2: Swap strings

s1 = "abc"
s2 = "xyz"

print "Before: "; s1, s2    ' Output: Before: abc   xyz
swap s1, s2
print "After:  "; s1, s2    ' Output: After:  xyz   abc

Example 3: Swap arrays

A = [1,2,3]
B = [7,8,9]

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  
This page was last edited on Tue, 22 Aug 2023 16:52:11 +0200 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.