mIRC Home    About    Download    Register    News    Help

Print Thread
#68301 17/01/04 06:47 PM
Joined: Jan 2004
Posts: 5
D
drakan Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jan 2004
Posts: 5
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.

Last edited by drakan; 17/01/04 06:48 PM.
#68302 17/01/04 09:32 PM
Joined: Dec 2003
Posts: 261
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Dec 2003
Posts: 261
Hi... maybe this $len(%first) <= $len(%limit) is never true... can't remember anything else that could be wrong...


velicha dusha moja Gospoda
#68303 17/01/04 09:39 PM
Joined: Jan 2004
Posts: 5
D
drakan Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jan 2004
Posts: 5
Thanks for the reply, though i don't think thats the problem, even when %limit is really high it still does it.

#68304 17/01/04 10:15 PM
Joined: Dec 2002
Posts: 332
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
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
}


#68305 17/01/04 10:21 PM
Joined: Jan 2004
Posts: 5
D
drakan Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jan 2004
Posts: 5
AFAIK thats not necessary.

#68306 17/01/04 10:29 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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.

#68307 17/01/04 10:34 PM
Joined: Jan 2004
Posts: 5
D
drakan Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jan 2004
Posts: 5
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.


Link Copied to Clipboard