| View previous topic :: View next topic |
| Author |
Message |
gerrit Newbie

Joined: 14 May 2004 Posts: 24
|
Posted: Wed Aug 25, 2004 6:38 am Post subject: Digit Problem |
|
|
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...
Thanks,
Gerrit _________________ ___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________ |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Wed Aug 25, 2004 7:31 am Post subject: |
|
|
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 |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Aug 25, 2004 11:00 am Post subject: |
|
|
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...
| 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 |
|
 |
gerrit Newbie

Joined: 14 May 2004 Posts: 24
|
Posted: Thu Aug 26, 2004 2:16 pm Post subject: |
|
|
Thanks Skit,Jules
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... 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 |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Sep 01, 2004 11:19 pm Post subject: |
|
|
| 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()... Just a little tip...  |
Here Skit,
This is your @Smaller function
| 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 |
|
 |
|
|
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
|
|