mIRC Homepage

$pos problem

Posted By: JoWie

$pos problem - 07/09/03 03:16 PM

i have a prob, if i do $pos(meis is test, is ,1) it returns 3, so mirc ignores the spaces in the string.
Is there a way to make mirc not ignore the spaces so it would show up 6?

(i use it in a script, so N is always 1)

and yes i did a search but that still answered my question... and i know " meis" isnt a word laugh
grtz, Jo-W (sry about my bad english smile )
Posted By: J0ke

Re: $pos problem - 07/09/03 03:34 PM

that's the way it works
$pos(meis is test,is,1) returns 3
$pos(meis is test,is,2) returns 6

/help $pos
Posted By: MircMania

Re: $pos problem - 07/09/03 03:51 PM

You could resort to using the $mid(%text,%number,4) identifier, you could increment the number until the end of the file and check for each four letters whether they equalled chr(32) $+ is $+ chr(32). If they do, you will know the %number you are on.
Posted By: codemastr

Re: $pos problem - 07/09/03 03:58 PM

Or you could just use $findtok.
$findtok(this is my test,is,1,32)
If I understand what he is saying, that should do what he wants.
Posted By: JoWie

Re: $pos problem - 07/09/03 04:09 PM

Joke wrote:
----------------------------
that's the way it works
$pos(meis is test,is,1) returns 3
$pos(meis is test,is,2) returns 6

/help $pos

----------------------------


the N is always 1 in my script...
Posted By: J0ke

Re: $pos problem - 07/09/03 04:15 PM

post your script so we can understand what r u trying to make
Posted By: JoWie

Re: $pos problem - 07/09/03 04:25 PM

Code:
alias NEW {
  set %is-item $$1
  set %is-value $$3-
  echo -s %is-item == %is-value
}


This is my code, now if I do /new testing blah is testing blah123
I get testing == blah testing blah123

so i tryd to make with the $pos to return the number where "is" is, then i used $left with the number from $pos.

Only then if i do "/new 324092is is testing" i get "324092"
Posted By: J0ke

Re: $pos problem - 07/09/03 04:42 PM

still does not make any sense...
Posted By: JoWie

Re: $pos problem - 07/09/03 04:43 PM

kk but the thing is i just wanna know how i can use a space in $cos
Posted By: JoWie

Re: $pos problem - 07/09/03 05:01 PM

ow damn i ment $pos instead of $cos (already edited my post)
Posted By: z00ey

Re: $pos problem - 07/09/03 05:50 PM

Code:
//echo # $pos(meis is test,$+($chr(32),is,$chr(32)),1)

..returns 5 (due to the space before "is").

Code:
//echo # $pos(meis is test,$+(is,$chr(32)),1)

..returns 6 like you want it to.. (btw, i agree, strange coding but i hope it helps you, whatever you re doing, lol smile)


Posted By: Rich

Re: $pos problem - 08/09/03 05:54 PM

//echo # $pos(meis is test,$+(is,$chr(32)),1)
echoes 3 because of meis, please test code before posting it, especially when it is this easy to test.

If you just want to split the text into the part before and after 'is' use this code:
Code:
alias new {
  var %pos = $findtok($$1-,is,1,32)
  var %is-item = $gettok($1-,1- $+ $calc(%pos - 1),32)
  var %is-value = $gettok($1-,$calc(%pos + 1) $+ -,32)
  echo -s %is-item == %is-value
}


If you really want the position of the 'i' character from 'is' try this:
Code:
$calc($len($gettok($1-,1- $+ $calc($findtok($1-,is,1,32) - 1),32)) + 1)

That will return the number of characters(including the space in front of 'is') before the word 'is'.
Posted By: JoWie

Re: $pos problem - 08/09/03 08:06 PM

lmao, ty cool
Posted By: JoWie

Re: $pos problem - 08/09/03 08:09 PM

please test code before posting it, especially when it is this easy to test.
----------------------
you dont get my question, i asked because it went rong when i whas testing smirk
© 2022 mIRC Discussion Forums