View previous topic :: View next topic |
Author |
Message |
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Nov 01, 2002 12:56 am Post subject: Swap two values with PARSE... |
|
|
Just discovered this, but it's pretty simple...
Code: |
%a = 1111
%b = 2222
PARSE "%a;%b", %b|%a
INFO a = %a@cr()@cr()b = %b
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Fri Nov 01, 2002 11:42 am Post subject: |
|
|
You can also do something like this, but the way above is shorter.
Code: | %a = 1111
%b = 2222
%c = %a
%d = %b
%a = %d
%b = %c
INFO a = %a@cr()@cr()b = %b |
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Fri Nov 01, 2002 7:28 pm Post subject: |
|
|
For people who don't know it:
If you want to swap values, you can also use shift, BUT the first variable (%1) will be emptied.
Handy if you make a program that uses a command-line input...
Code: | %1 = 1
%2 = 2
%3 = 3
%4 = 4
%5 = 5
info %1 - %2 - %3 - %4 - %5
shift
info %1 - %2 - %3 - %4 - %5
shift
info %1 - %2 - %3 - %4 - %5 |
|
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Nov 01, 2002 8:47 pm Post subject: |
|
|
Well... the idea of using PARSE here was to swap two values
on one line of code with no extra variable(s) needed.
Until now, I've used one temporary var similiar to this:
%%tmp = %a
%a = %b
%b = %%tmp
%%tmp = ""
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Fri Nov 01, 2002 8:54 pm Post subject: |
|
|
I know, and now it's only on one single line! |
|
Back to top |
|
|
|