Hello Charles
PB has a swap statements which swap the values between 2 variables, what would be
the equivalent O2 statement ?
Please see
http://manmrk.net/tutorials/basic/PowerBASIC/pbcc5/swap_statement.htm (http://manmrk.net/tutorials/basic/PowerBASIC/pbcc5/swap_statement.htm)
Thanxx
I think charles has already put an example of this in an answer to Mike
I believe it would be using pointer and swapping addresses with @
I think it would be something like this
A ,B
*P
@P=@A
@A=@B
@B=@P
in case instead of values exchange memory addresses
Hi Chris and Eduardo,
This will work for any primitive type, or flat UDT
macro Swap(a,b, c)
=====================
typeof(a) c=a
a=b
b=c
end macro
int a=1, b=2
swap a,b
Thanxx a lot both of you
this O2 Swap macro is even better than PB Swap, bcos PB Swap statement will require the same type of primitives
for the 2 variables a and b