Swap command?

Blitz3D Forums/Blitz3D Beginners Area/Swap command?

Farflame(Posted 2005) [#1]
Is there a swap command in Blitz to swap the values of two variables? I.e Swap A,B? Or would I have to do C=A, A=B, B=C?


Lane(Posted 2005) [#2]
you could write your own function to do this if you really need to abbreviate the current method.
You are correct.
C=A
A=B
B=C

I'm not sure why you would need to except maybe a billboard with 10 lines of text.

For I = 1 to 9
Label(I)=Label(I+1)
Next I
Label(10) = "" ; Clear the last line

This scrolls the text up one line every time it's used assuming the Lables are printed in Ascending order.


ucode(Posted 2005) [#3]
If you don't want to use an extra variable you can do this (it will swap a and b):

a=a*b
b=a/b
a=a/b


WolRon(Posted 2005) [#4]
a=a*b
b=a/b
a=a/b
Although that can lead to rounding/floating point errors...


Mark Tiffany(Posted 2005) [#5]
and doesn't work so well with strings...