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 


@HEX() function

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Feb 07, 2002 11:42 am    Post subject: @HEX() function Reply with quote

I use the @HEX() function to format some values. My problem is that if the resulting hex number has one or more leading zeros, @HEX() will remove them automatically (i.e. 01234 will be 1234).

Normally that would not be an issue, but in this case I really to keep leading zeros. Anyone has an idea how to do this?

Thanks.

Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
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: Thu Feb 07, 2002 7:46 pm    Post subject: Reply with quote

How about a loop to check for leading zeroes before
the @hex() function, save them, and append the
@hex() result to the zeroes?

Something like this maybe:
__________________________________________________________________________________________________________________________
Code:

%n = 0012345
%s = ""
%x = 1
REPEAT
  if @equal(@substr(%n, %x), 0)
     %s = %s@substr(%n, %x)
  end
  %x = @succ(%x)
UNTIL @not(@equal(@substr(%n, %x),0))

%n = %s@hex(%n)
INFO test %n

_________________
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
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Fri Feb 08, 2002 7:42 am    Post subject: Reply with quote

Hi again, Mac!

Thanks for the suggestion. But I don't think that it will work because input values do not necessarily have any leading 0's - they appear in hex output, or rather they don't because the @hex() function removes them.

Let me give you an example:

Code:
%i = 121843147
%o = @hex(%I)
info Input (%i) = Output (%o)


So output is 7432DCB, but it should have been 07432DCB

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Fri Feb 08, 2002 12:29 pm    Post subject: Reply with quote

The following may be what you want:

Code:

%i = 121843147
%o = @hex(%I,8)
info Input (%i) = Output (%o)



Tommy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Fri Feb 08, 2002 1:52 pm    Post subject: Reply with quote

I had tried that one (defining length of @hex() output) already. It works fine, but only when working with fixed-length values. Problem is that my input (and therefore output) has varying length.

But hey, it gives me an idea now. There just might be a way for me to determine the expected length of each @hex() output - if that's possible I can follow your suggestion..

%i = 121843147
%%length = "expected length"
%o = @hex(%I,%%length)

I will try to rewrite my routines and see if this puppy will run! Thanks

Dread Cool

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
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 -> General Help 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