mIRC Home    About    Download    Register    News    Help

Print Thread
#80438 24/04/04 12:27 PM
Joined: Apr 2004
Posts: 1
kabuto Offline OP
Mostly harmless
OP Offline
Mostly harmless
Joined: Apr 2004
Posts: 1
Hello,

I have a custom identifier as follows

alias dur5 return $replace($gettok($dur3($1),1,32),10,ten,1,one,2,two,3,three,4,four,5,five,6,six,7,seven,8,eight,9,nine) $gettok($dur3($1),2,32) $iif(10 // $durtok($1),$replace($durtok($1),10,ten,20,twenty,30,thirty,40,forty,50,fifty)) $iif($durtok($1) > 10,$iif($durtok($1) < 20,$replace($durtok($1),11,eleven,12,twelve,13,thirteen,14,fourteen,15,fifteen,16,sixteen,17,seventeen,18,eighteen,19,nineteen))) $iif($len($durtok($1) == 2),$iif(10 \\ $durtok($1),$replace($left($durtok($1),1),2,twenty,3,thirty,4,forty,5,fifty)))) $+ $iif($len($durtok($1) == 1),$iif(10 \\ $durtok($1),$replace($right($durtok($1),1),1,one,2,two,3,three,4,four,5,five,6,six,7,seven,8,eight,9,nine)))) $gettok($dur3($1),4,32))

which converts numeric to alphanumeric ie 20 -> twenty. I use this in my mp3 addon. What it's supposed to do is convert 4 minutes 20 seconds to four minutes twenty seconds which it does with two exceptions. It converts seconds below 10 like 9nine and numbers between 10 and 20 like 11eleven or 12twelve. Can anybody help me on this?


Kabuto
DALnet
UIN:9836281
#80439 24/04/04 11:44 PM
Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
This is a quick reply - I don't have time at the moment to consider a full solution but ...

.. as a programmer, the sight of such spaghetti always scares me! I would consider doing this in stages (instead of one line).

Alias Ordinal1 {
if $1 = 1 then return "one"
.
.
.
if $1 = 9 then return "nine"
if $1 = 10 then return "ten"
.
.
.
if $1 = 19 then return "nineteen"
}

alias Ordinal2 {
if $1 = 10 then return "ten"
.
.
.
if $1 = 90 then return "ninety"
}

alias Level {
if $1 = 2 then return "hundred"
.
.
.
if $1 = 6 then return "million"
}

alias convert {
/var %clevel = length of $1
/var %cnum = $1
/var %canswer = ""

while %clevel > 1{
take first char
%canswer = %canswer + Ordinal1(first_char) + level(%clevel)
%cnum = %cnum less first char
dec %clevel
}
// the following is if num betwen 99 and 0
{
if %cnum >= 20 then {
%canswer = %canswer + Ordinal2(first char) + Ordinal1(secondchar)
}
else // %cnum is under 20
%canswer = %canser + Ordinal1(%cnum)
}
}


As I have said, I have not put the above through the wringer and is in some sort of psuedo code.

Someone else can have the fun of putting it together :-) But I think the above is a more generic code that could be used outside your time issue!

Cheers,
DK

(edited to fix up numerous typos that appears in the time between typing it out and pressing the submit button!)







Last edited by Darwin_Koala; 24/04/04 11:48 PM.

Darwin_Koala

Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!
#80440 25/04/04 01:14 PM
Joined: Dec 2002
Posts: 774
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
num2txt {
if ( $1 >= 100 ) return TOO MUCH
var %var = $1
var %var1 = one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen
var %var2 = ten twenty thirty forty fifty sixty seventy eighty ninety
var %out
if ( $1 >= 20 ) return $gettok(%var2,$left($1,1),32) $iif($right($1,1) != 0,$gettok(%var1,$right($1,1),32))
return return $gettok(%var1,$1,32)
}


Code:
//if ( khaled isgod ) echo yes | else echo no

Link Copied to Clipboard