mIRC Home    About    Download    Register    News    Help

Print Thread
#12847 24/02/03 04:52 PM
Joined: Feb 2003
Posts: 23
C
cybah Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 23
test {
var %x = 1
while (%x <= $len($1-)) {
var %y = %y $+ (- $+ $mid($1-,%x,1) $+ -)
inc %x
} return %y
}

//echo -a $test(testing)
It only echo's the first letter and not the whole word.
I don't know why confused

Help me plz blush

#12848 24/02/03 05:15 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
"return %y" should be on a new line.

#12849 24/02/03 05:30 PM
Joined: Feb 2003
Posts: 23
C
cybah Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 23
Daimn,that was so simple and I din't found it blush
TY wink

#12850 24/02/03 06:05 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
In addition to Nimue's fix, I'd suggest these changes as well because they say what you mean.
Code:

test {
  var %y, %x = 1, %1- = $replace($1-, $chr(32), $chr(127))
  while $mid(%1-, %x, 1) != $null {
    %y = %y $+ (- $+ $ifmatch $+ -)
    inc %x
  }
  return $replace(%y, $chr(127), $chr(32))
}

This version allows for spaces by first replacing spaces with a hard space, then reversing the process at the end.

Using the $mid() as your while condition allows you to use $ifmatch which will hold the character found. You don't need to keep recomputing $len($1-) and then comparing that to whatever %x is. If the $mid() returns a character, then you can process that character (the $ifmatch). cool If you were going to use the length of the string for something else, then using $len() would be reasonable, but you're not and don't need it. laugh

//var %text = Testing this, ok? | echo -a $testing(%text)
(-t-)(-e-)(-s-)(-t-)(-i-)(-n-)(-g-)(- -)(-t-)(-h-)(-i-)(-s-)(-,-)(- -)(-o-)(-k-)(-?-)


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#12851 24/02/03 06:30 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
There's no need to replace spaces, as they are being enclosed in (- -). smile Ccontrol codes will skew the result
Code:
test {
  var %x = 1,%y
  while $mid($strip($1-), %x, 1) {
    %y = %y $+ (- $+ $ifmatch $+ -)
    inc %x
  }
  return %y
}
(-t-)(-e-)(-s-)(-t-)(-i-)(-n-)(-g-)(- -)(-t-)(-h-)(-i-)(-s-)(-,-)(- -)(-O-)(-K-)(-?-)

#12852 24/02/03 09:44 PM
Joined: Jan 2003
Posts: 108
H
Vogon poet
Offline
Vogon poet
H
Joined: Jan 2003
Posts: 108
You wouldnt by chance be trying to make a mode parse'r, i just finished mine, and also some mode settings based on char lengths and what not. :P


Link Copied to Clipboard