 |
TonDiening GURU

Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Sat Mar 01, 2003 9:21 pm
Incremental list of characters |
Brain dead and can't figure out a simple way to implement a method
to track a counter and spit out a list like:
a,b,c, .. z, aa, ab, ac, .. az, ba, bb, bc, .. , zz, aaa, aab, for a
counter going to possibly 2000.
Can't seem to get the mod and div statements working with %if's.
Ton Diening |
|
|
 |
Kjata GURU

Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sat Mar 01, 2003 11:37 pm |
Is this to be done in a sequential way, or do you need the next value to be returned when given the previous one as input? For sequential:
#VAR combs "a"
#LOOP 1,2000 {#SH @combs;#IF (%rightback(@combs, 1) = "z") {#VAR index {%eval(%len(@combs) - 1)};#WHILE (@index and (%copy(@combs, @index, 1) = "z")) {#ADD index -1};#IF (@index) {#VAR combs {%concat(%copy(@combs, 1, @index - 1), %char(%ascii(%copy(@combs, @index, 1)) + 1), %repeat("a", %len(@combs) - @index))}} {#VAR combs {%repeat("a", %len(@combs) + 1)}}} {#VAR combs {%concat(%leftback(@combs, 1), %char(%ascii(%rightback(@combs, 1)) + 1))}}}
Kjata |
|
|
 |
Emit Magician
Joined: 24 Feb 2001 Posts: 342 Location: USA
|
Posted: Sat Mar 01, 2003 11:58 pm |
Here is a solution that takes the number as argument, and puts the string in variable @out:
#var count %1
#var out ""
#if (@count > 676) {
#if (@count 676 < 26) {div = 677} {div = 676}
ca = %eval( @count/@div)
out = %char( @ca + 96)
count = %eval( @count - (676 * @ca) + 26)
}
#if (@count > 26) {
#if (@count 26 = 0) {div = 27} {div = 26}
ca = %eval( @count/@div)
out = %concat( @out, %char( @ca+96))
count = %eval( @count - (26 * @ca))
}
#if (@count = 0) {
out = %concat( @out, "a")} {
count = %eval( @count 26)
#if (@count = 0) {count = 26}
out = %concat( @out, %char( @count+96))
}
--------
moon.icebound.net:9000 |
|
|
 |
TonDiening GURU

Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Sat Mar 01, 2003 11:59 pm |
I'd need the next value to be returned when given the previous one as input.
Used to name different odd elements and be able to reference them with that
key. Looking at your concepts now. Thanks for the quick answers Kjata and Emit.
Ton Diening
Edit: Awesome, thanks guys just what I needed! |
|
|
 |
Penjulum Beginner
Joined: 14 Oct 2000 Posts: 14 Location: USA
|
Posted: Tue Mar 04, 2003 7:26 am |
Using the same basic variables of Emit:
#alias Set
#var Count {%left( %1, 3)}
#alias Next
#var nCount1 %ascii( @Count)
#var nCount2 %ascii( %right( @Count, 1))
#var nCount3 %ascii( %right( @Count, 2))
#math nCount3 @nCount3+1
#if @nCount3>=123 {
#var nCount3 97
#math nCount2 @nCount2+1
}
#if @nCount2>=123 {
#var nCount2 97
#math nCount1 @nCount1+1
}
#if @nCount1>=123 {
#var nCount1 97
}
#var NextCount {%char( @nCount1)%char( @nCount2)%char( @nCount3)}
#show @Count + 1 = @NextCount
#var Count @NextCount
Tested Offline zMud v6.53 beta (trial) |
|
|
 |
|
|
|
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
|
|