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 


Digit Problem

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
gerrit
Newbie


Joined: 14 May 2004
Posts: 24

PostPosted: Wed Aug 25, 2004 6:38 am    Post subject: Digit Problem Reply with quote

Hi all,
I knew that this is may a small Problem, but I run now several times into it...

I want to Count numbers like 0001,0002,0003....0010.... for filenames, so that I can load them again into a sorted List....
does someone knew an easy way to count like this...

I helped me out right now with something like if x>10 than... if x>100 than... But when I go to a Million Numbers I would get crazy... Insane

Thanks,
Gerrit

_________________
___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________
Back to top
View user's profile Send private message Visit poster's website
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Wed Aug 25, 2004 7:31 am    Post subject: Reply with quote

I'm not sure I understand the question, but I think what you want to do is start counting at %I = 1000000 (say) and then use @strdel(%I,1,1) in the filename.
_________________
The Tech Pro
www.tech-pro.net
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: Wed Aug 25, 2004 11:00 am    Post subject: Reply with quote

I think he just wants to create filenames with leading zero's, so that they will be aligned in proper order (unlike filenames which start with "1", "10", "100", etc.), like this:

Quote:
001 - file.txt
002 - file2.txt
010 - file28362.txt


If so, this function does what you want... Smile

Code:
#define function,FixNumber

info @FixNumber(34,5)

exit

:FixNumber
# @FixNumber(<input number>,<Fixed length>)
if @greater(@succ(@len(%1)),%2)
  exit %1
else
  exit @fill(@diff(%2,@len(%1)),00000000000000000000000000000000000000)%1
end

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
gerrit
Newbie


Joined: 14 May 2004
Posts: 24

PostPosted: Thu Aug 26, 2004 2:16 pm    Post subject: Reply with quote

Thanks Skit,Jules Smile

Skit's Code is workling fine....
I found also some other solution in this forum, witsh works too.
Sometimes I need to think more logical to solve a Probelm. I should really go more for Functions, insted to write Lines of Code to solve the Problem.

But eaven with this, I learned again a lot...Wink
Code:
@Greater
Already was searching for something to compait two numbers.

Thanks again,
Gerrit


Code:

:FCount
  %%Digits = %2
  %%Counter = %1
  %%TempCounter = %%Counter
    IF @unequal(@len(%%TempCounter),%%Digits )
      REPEAT
        %%TempCounter = "0"%%TempCounter
      UNTIL @equal(@len(%%TempCounter),%%Digits )
    END
exit %%TempCounter
[/code]
_________________
___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________
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: Thu Aug 26, 2004 2:58 pm    Post subject: Reply with quote

Gerrit, you wrote you search a while for a function like @greater(), but please note there is not a function like "@smaller()", since this is the same as swapping the parameters of @greater()... Wink Just a little tip... Smile
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Wed Sep 01, 2004 11:19 pm    Post subject: Reply with quote

Skit3000 wrote:
Gerrit, you wrote you search a while for a function like @greater(), but please note there is not a function like "@smaller()", since this is the same as swapping the parameters of @greater()... Wink Just a little tip... Smile


Here Skit,
This is your @Smaller function Laughing

Code:

#DEFINE FUNCTION,SMALLER
%A = 1
%B = 0

If @Smaller(%B,%A)
  Info B is smaller than A
Elsif @Greater(%B,%A)
  Info B is greater than A
Else
  Info A & B are equal
End
Exit
:SMALLER
EXIT @Both(@Not(@Greater(%1,%2)),@Not(@Equal(%1,%2)))

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
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