swap - exchange the values of two variables


swap Var1, Var2


Swap interchanges the values of the two variables named as arguments.  The arguments Var1 and Var2 are the names of two variables or array elements and must be either both numeric or both string.  Any type variables may be swapped (integer, single-precision, double-precision, string).  For example,
	a% = 1
	b! = 3.9
	swap a%, b!
	print a%, b!
would produce
	 4            1 


The program
	undone = 1
	while undone
		undone = 0
		for i = 1 to j - 1
			if a$(i) > a$(i+1) then_
				swap a$(i), a$(i+1) : _
				undone = 1
		next i
sorts the elements of the string array a$ into lexicographic order based on the ASCII representation.  The array a$ was defined with j elements. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber