mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 54
B
Babel fish
OP Offline
Babel fish
B
Joined: Oct 2005
Posts: 54
Mmkay I get the following error, "* /set: line too long (line 55, Fun stuff)" from the following alias
Code:
menu channel {
  Stuff
  .Generate Random Number : /gen.randnum $$?"Digits:"
}
alias gen.randnum {
  if ($1 == $null) || ($1 <= 0) halt
  if ($1 isnum) {
    var %d $2
    var %i 0
    :regen
    inc %i 1
    set %t %t $+ $rand(1,9)
    if (%i == %d) {
      echo 4 %t
      unset %t
    }
    else {
      goto regen
    }
  }
} 


Thanks if you can help me figure out what the problem is laugh


Chat NSN
My Server: sleepystickman.ircxpro.com
Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
The variable %t has become too long. I'm guessing you are generating random number sequences of a large number of digits. btw why not use $rand(0,9), its not truely random if you restrict it.

To solve the problem, add an if statement to check the length of variable %t, if its length is more than X charactors, echo the line, unset the var (or set it to the next single random number) and continue.

if (%t >= X) { echo 4 %t | set %t $rand(0,9) }
else { set %t %t $+ $rand(0,9) }

Also, doesn't look like you use %t outside of this alias, plus you unset it at the end, so it would be more efficient to use var %t rather than set %t

Edit :: and indeed sk's example is a much better way to do it. Although you would still need to alter it to handle long sequences or you will get a similar string too long error.

Last edited by Om3n; 06/11/05 06:00 AM.

"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
I'm not too sure what you was trying to do but try this:

Code:
menu channel {
  Stuff
  .Generate Random Number : /gen.randnum $$?"Digits:"
}
alias gen.randnum {
  echo -a $remove($($str($+($!rand(1,9),$chr(32)),$1),2),$chr(32))
}


Or /gen.randnum 5 to test remotely.

-Andy

Joined: Oct 2005
Posts: 54
B
Babel fish
OP Offline
Babel fish
B
Joined: Oct 2005
Posts: 54
I was trying to build a more complicated random number generator, for more random numbers :P
It would make every digit a random number between 1-9 and put all of them together
then Echo


Chat NSN
My Server: sleepystickman.ircxpro.com
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
I think thats what my alias does.. *shrugs* it's getting late it's all mumbo jumbo to me right now..

-Andy

Joined: Oct 2005
Posts: 54
B
Babel fish
OP Offline
Babel fish
B
Joined: Oct 2005
Posts: 54
shocked i found the error, but it's a bad one, it makes the variable HUGE, example:
%t 4342521733455654544761556353542911813498257921412599276932264557965766867234264854428628673568152415632434389763859237819575588944421844498369729467158156943657336669841229893617961961162414939276216299833797497918165124114536536169836546976244631987596318757318995669866276146178347571121419499872683714346138338272764157372182447219143732617249163588522274552455894522214289953956935419368249921413758549721321471772899433687897346349667981133115348891494938377659675676861411615269687719333135148172199876854418876487537724959887678371648354171748779833561945349552616784593178945816956172697625891679261419231597451649543338978177673923368253955125211469159922121163886118821219951899486346681863719695953317897315734428264232599217769819854665415871967318875199673657827292277743427828628995772777434246711468767354257862537648588248369659966555961541162223517456115742454411319639377943472728856669299367976817589343325398176417436924893

oh my...
now i need to find a way to make it actually stop :|


Chat NSN
My Server: sleepystickman.ircxpro.com
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
your code was screwing up becuase it carried on untill %i == %d, and %i couldnt equal %d since %d was nothing $2 has no value, u wanted $1

heres some tighter and more robust code. 1 to 940 digits allowed.


Code:
menu channel {
  Stuff
  .Generate Random Number : /gen.randnum $$?"Digits (1-940):"
}
alias gen.randnum {
  if ($1 isnum 1-940) {
    var %d, %i = $int($1)
    while (%i) { var %d %d $+ $rand(1,9) | dec %i }
    echo 4 %d
  }
}

Joined: Jul 2005
Posts: 56
W
Babel fish
Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
/help hash tables

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
/help hash tables


And just what possable constructive use could a hash table be in what was requiered here?


Link Copied to Clipboard