forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Swap two values with PARSE...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Knowledge Base
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Nov 01, 2002 12:56 am    Post subject: Swap two values with PARSE... Reply with quote

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 Smile

_________________
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
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Fri Nov 01, 2002 11:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Nov 01, 2002 7:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Nov 01, 2002 8:47 pm    Post subject: Reply with quote

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 Smile

_________________
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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Nov 01, 2002 8:54 pm    Post subject: Reply with quote

I know, and now it's only on one single line!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Knowledge Base All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group