mIRC Homepage

asdjfgljhjdf @ this

Posted By: Frog

asdjfgljhjdf @ this - 16/12/02 03:58 AM

Why isnt this thing working right? smirk

alias bk2 {
var %x 1
while (%x <= $gettok($1-,0,32)) {
var %i = $len($gettok($1-,%x,32))
while (%i > 0) {
var %o = $+(%o,$mid($gettok($1-,%x,32),%i,1))
dec %i
}
inc %x
}
if ($isid) return %o
say %o
}

It's being a pos and not adding spaces.. I know that doesnt have any kind of space-adding in it, but even when I try, it doesnt work. I'm annoyed as hell with it, and that's probably why I cant get it, but it's getting really annoying and, bah.
Posted By: Dana

Re: asdjfgljhjdf @ this - 16/12/02 04:02 AM

Don't know if it makes a difference or not, but you forgot the equation sign for the %x. var %x = 1

Dana
Posted By: Frog

Re: asdjfgljhjdf @ this - 16/12/02 04:15 AM

/me tries that..

(few minutes later)

Nope. Didnt work, bah.
Posted By: Dana

Re: asdjfgljhjdf @ this - 16/12/02 04:38 AM

I added a bit to it ...

Code:
alias bk2 {
  var %x = 1, %result = ""
  while (%x &lt;= $gettok($1-,0,32)) {
    var %i = $len($gettok($1-,%x,32))
    while (%i &gt; 0) {
      var %o = $+(%o,$mid($gettok($1-,%x,32),%i,1))
      dec %i
    }
    inc %x
    set %result $instok(%result,%o,$calc($numtok(%result,32) + 1),32)
    unset %o
  }
  if ($isid) return %result
  echo -s %result
}
I *think* that this is what you want, but not sure.
Posted By: Frog

Re: asdjfgljhjdf @ this - 16/12/02 04:50 AM

*sighs heavily* Yes, it is, but I want to know why it wont work with var %o = $+($chr(32),%o,...) and such. It's beginning to piss me off a little.
Posted By: Dana

Re: asdjfgljhjdf @ this - 16/12/02 05:00 AM

I suspect that it has something to do with the way that mIRC parses spaces. Because if you replace all the "regular" spaces with "hard" spaces ($chr(160)), then the script works just like you want it to as well:

Code:
alias bk2 {
  var %x = 1
  var %start = $replace($1-,$chr(32),$chr(160))
  while (%x &lt;= $gettok(%start,0,32)) {
    var %i = $len($gettok(%start,%x,32))
    while (%i &gt; 0) {
      var %o = $+(%o,$mid($gettok(%start,%x,32),%i,1))
      dec %i
    }
    inc %x
  }
  if ($isid) return %o
  echo -s %o
}
Posted By: Frog

Re: asdjfgljhjdf @ this - 16/12/02 05:05 AM

alias bk {
var %i $len($1-),%o
while (%i) {
var %o = $+(%o,$mid($1-,%i,1),$chr(32))
dec %i
}
if ($isid) return %o
say %o
}

Does the same thing.. it reverses everything. What I'm trying to do is keep the words in the same order, but reversed. And I've partially got it, but the spaces are being ...
Posted By: Dana

Re: asdjfgljhjdf @ this - 16/12/02 05:16 AM

First of all, I think that you should just use the script that I gave you. :P If it works, don't mess with it! wink

Secondly, I don't understand where in your script, you're telling it to add the spaces.

Basically, you're breaking down the input into words and then reversing the order of the letters for each word "$mid($gettok($1-,%x,32),%i,1)" before moving on to the next word. But you're not taking any spaces from the original input and adding it to %o. Or am I blind?
Posted By: Frog

Re: asdjfgljhjdf @ this - 16/12/02 05:23 AM

Like I said, even when I took adding spaces into account with the $mid, it didnt work. BUT, I have it now.

alias bk2 {
var %x 1
while (%x <= $gettok($1-,0,32)) {
var %i = $len($gettok($1-,%x,32)),%b
while (%i) {
%b = $+(%b,$mid($gettok($1-,%x,32),%i,1))
dec %i
}
var %o = %o %b
inc %x
}
if ($isid) return %o
say %o
}

Anyway, g'night, and thanks for the help.
Posted By: watcher

Re: asdjfgljhjdf @ this - 16/12/02 05:40 AM

Code:
 alias bk2 {
  var %i 1,%x,%t,%r
  while %i &lt;= $numtok($1-,32) {
    %x = $len($gettok($1-,%i,32))
    while %x { %t = %t $+ $mid($gettok($1-,%i,32),%x,1) | dec %x }
    %r = %r %t
    %t = ""
    inc %i
  }
  if $isid { return %r }
  say %r
} 

cool
© 2020 mIRC Discussion Forums