mIRC Homepage

Problem with a script

Posted By: drakan

Problem with a script - 17/01/04 06:47 PM

I have been working on a mirc rpg-character-name-generator lately and so far everything worked out fine.
If it weren't for one little part of the script:

alias limited {
var %first
var %amount
%amount = $did(namegen,3)
var %limit
%limit = $did(namegen,11)
:begin
%first = $read(namegen\pre.txt) $+ $read(namegen\suff.txt)
if ($len(%first) <= $len(%limit)) { did -a namegen 5 %first | goto next }
else goto begin
:next
dec %amount
if (%amount != 0) goto begin | else goto end
:end
last
}

When this alias is used it freezes my mIRC for some reason.
Any idea why it does this? Thanks.
Posted By: milosh

Re: Problem with a script - 17/01/04 09:32 PM

Hi... maybe this $len(%first) <= $len(%limit) is never true... can't remember anything else that could be wrong...
Posted By: drakan

Re: Problem with a script - 17/01/04 09:39 PM

Thanks for the reply, though i don't think thats the problem, even when %limit is really high it still does it.
Posted By: Cheech

Re: Problem with a script - 17/01/04 10:15 PM

isnt sure either ? but
Code:
  
else goto begin
:next
dec %amount
if (%amount != 0) goto begin | else goto end
:end
last
}
you dont have any open or close brackets on those if statements ? 


Code:
  
else  [color:blue] { [/color]  goto begin  [color:blue]}  [/color] 
:next
dec %amount
if (%amount != 0)  [color:blue] { [/color] goto begin [color:blue] } [/color]  
else  [color:blue] { [/color] goto end [color:blue] } [/color] 
:end
last
}

Posted By: drakan

Re: Problem with a script - 17/01/04 10:21 PM

AFAIK thats not necessary.
Posted By: DaveC

Re: Problem with a script - 17/01/04 10:29 PM

Is %limit a number of chars allowed or a representer of length such as XXXXX represents 5, becuase your not checking if the length of %first is <= to %limit but the length of the string in limit.
maybe it should be
if ($len(%first) <= %limit) { ...


If thats not right then i would say you have a problem in the data thats being used somwehere.
replace your script with this...

alias limited {
var %first
var %amount
%amount = $did(namegen,3)
var %limit
%limit = $did(namegen,11)

echo -s $time CP1 "%amount" %amount -- "%limit" %limit -- "%limit-lenth" $len(%limit)

:begin
%first = $read(namegen\pre.txt) $+ $read(namegen\suff.txt)

echo -s $time CP2 "%amount" %amount -- "%first" %first -- "%first-length" $len(%first)

if ($len(%first) <= $len(%limit)) { did -a namegen 5 %first | goto next }
else goto begin
:next
dec %amount

echo -s $time CP3 "%amount" %amount

if (%amount != 0) goto begin | else goto end
:end
last
}

I just added 3 check points, that display relevent data to that section into the status window. you should be able to see where its looping when it shouldnt.

ps ctrl-break should halt it.
Posted By: drakan

Re: Problem with a script - 17/01/04 10:34 PM

Quote:
Is %limit a number of chars allowed or a representer of length such as XXXXX represents 5, becuase your not checking if the length of %first is <= to %limit but the length of the string in limit.
maybe it should be
if ($len(%first) <= %limit) { ...


That actually worked!! smile
Thanks, I can't believe it was actually something this simple.
© 2020 mIRC Discussion Forums