$maketok(word,C) identifier

By rhasttaff on Oct 18, 2008

Hi!!!
I was trying some things in my mIRC, and noticed a lack of something,
then sought in the mIRC help file and don't found it, I tried here on the site and don't found it, so i decided to create my own.

sorry if already there is one of this done, but i tried to find it!!!

is it an identifier to make token with ONLY ONE WORD and the C parameter

syintax: $maketok(word,C)
The C parameter is the ascii value of the character separating the tokens.

/echo $maketok(word,32) <--| will return w o r d
/echo $maketok(word,44) <--| will return w,o,r,d
/echo $maketok(word,46) <--| will return w.o.r.d
/echo $maketok(word,2) <--| will return word
/echo $gettok($maketok(word,46),1,46) <--| will return-> w
/echo $gettok($maketok(word,46),3,46) <--| will return-> r
/echo $gettok($maketok(word,46),4,46) <--| will return-> d
/echo $gettok($maketok(word,46),$r(1,$len($1)),46) <--| will return-> a random letter from the word

Jah Bless´´´

/*
#->         By rhasttaff        <-#    
#-> $maketok(word,C) identifier <-# 

is it an identifier to make token with ONLY ONE WORD and the C parameter

syintax: $maketok(word,C)
The **C** parameter is the ascii value of the character separating the tokens.

/echo -a $maketok(word,32) |--> will return w o r d
/echo -a $maketok(word,44) |--> will return w,o,r,d
/echo -a $maketok(word,46) |--> will return w.o.r.d
/echo -a $maketok(word,33) |--> will return w!o!r!d
===============================================

some uses:
====
to return:

r
h
a
s
t
t
a
f
f
using: /eg1 rhasttaff
and:
alias eg1 {
  var %a = $1, %b = 1
  while (%b <= $len(%a)) {
    echo -a $gettok($maketok(%a,46),%b,46)
    inc %b
  }
}
======================================================
to return:

f
f
a
t
t
s
a
h
r

using: /eg2 rhasttaff
and:
alias eg2 {
  var %a = $1, %b = $len(%a)
  while (%b >= 1) {
    echo -a $gettok($maketok(%a,46),%b,46)
    dec %b
  }
}
========================================================
and by type /eg3 rhasttaff
with:
alias eg3 {
  echo -a --> $maketok($1,46)  <--I will return-> r.h.a.s.t.t.a.f.f
  echo -a --> $gettok($maketok($1,46),3,46)  <--I will return-> a
  echo -a --> $gettok($maketok($1,46),$r(1,$len($1)),46) <--I will return-> maybe ->r<- maybe ->f<-   ...any random letter from the word-> rhasttaff
}

ATTENTION if you want test these examples you may put them below to the line from: (*/)
=================================================================================
*/

alias maketok {
if (!$2) { echo 4 -as * ERROR $eval($maketok,0) too few parameters | halt }
  var %b- = 0 
  while (%b- <= $len($1)) {
    var %c- =  $iif(%b- < 1,$left($1,1),$left($right($1,- $+ %b-),1))
    if (%c-) { var %d- = $iif($2 != 32,%d- $+ %c- $+ $chr($2),%d- %c-)  }
    inc %b-
  }
  return $iif($2 = 32,%d-,$left(%d-,-1))
}

Comments

Sign in to comment.
Gummo   -  Oct 20, 2008

I see the $chr($2) doesn't work there..
So you know, you don't actually need to have text stored to do that, though you would need to use /(?<!^)(?!$)/g for complete accuracy. However, token identifiers ignore null tokens, so it's not especially important here.

 Respond  
Imrac   -  Oct 20, 2008

Gummon: No, First it doesn't have "\t $+ $chr($2)", second you need a dot to match the first letter, so it doesn't add a token before the first letter, third $2 doesn't work in the replace part of the token (don't ask me why, it just doesn't)

 Respond  
Gummo   -  Oct 20, 2008

Wouldn't this then work also?

alias maketok return $regsubex($1,/(?!$)/g,$chr($2))
 Respond  
Imrac   -  Oct 20, 2008
alias maketok {
  var %2 = $chr($2)
  if ($isid) { return $regsubex($1,/(.(?!$))/g,\1 $+ %2) }
}
 Respond  
rhasttaff   -  Oct 20, 2008

Hallo!! Thanks for comments and incentive Brothers :)
^Neptune yes man it will do exactlly as you posted.
/echo -a $maketok(Hello Pretty world,46) = H.e.l.l.o. .P.r.e.t.t.y. .w.o.r.l.d
but
/echo -a $maketok(Hello Pretty world,32) = H e l l o P r e t t y w o r l d

Gummo
yeah i have alread used $mid others times, i don't know wtf i was thinking when i dont see that, including it culd be used to make this identifier, i think i lost this point. but it was a problem in taht moment and after killing some neurons i made it :\
as you sayd, but ok :|

to use it now i like more in

/echo -a $maketok(Hello Pretty World,2) = Hello Prettyy World
/echo -a $maketok(Hello Pretty World,31) = Hello Prettyy World

Thanks again!!

Jah Bless´´´

 Respond  
Gummo   -  Oct 19, 2008

The purpose is to make $mid with tokens instead..
Have you even thought about it, ^Neptune?

 Respond  
^Neptune   -  Oct 19, 2008

It's basically /tokenize but for each letter.

 Respond  
Gummo   -  Oct 19, 2008

..So $gettok($maketok(text,46),2,46) is the same as $mid(text,2,1).
That's what its use is, yes?
I don't see the point, really, but ok.

 Respond  
^Neptune   -  Oct 19, 2008

Pretty nice actually. Although I wouldn't call it $maketok. Maybe... $septok? Short for seperate-token? :P

Would be nice to fix the spaces problem though. I don't see why you couldn't just interpret $chr(32) ad make it come out. Such as:

$maketok(hello there,46)

Could return:

h.e.l.l.o. .t.h.e.r.e

Good work though. 7/10

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.