egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

string editing

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
wiz(andrew)
Voice


Joined: 01 Sep 2006
Posts: 5

PostPosted: Fri Sep 01, 2006 8:04 am    Post subject: string editing Reply with quote

hello
i need few proc/command that match mirc's commands $mid

Code:
  $mid(text,S,N)
  Returns N characters starting at position S in text.
 
  $mid(othello,3,4)  returns hell
 
  If N is zero, it returns the number of characters from S to the end of the line.
 
  You may also use negative numbers for S or N.


what i am trying to is to take out lets say the secound char from a string etc..

string "abc 123 qwe"
then to take the 2chr "b" or the 5 till the 8 "123 "

Thx For the help
Back to top
View user's profile Send private message
krimson
Halfop


Joined: 19 Apr 2006
Posts: 86

PostPosted: Fri Sep 01, 2006 8:11 am    Post subject: Reply with quote

http://www.tcl.tk/man/tcl8.4/TclCmd/string.htm#M40
Back to top
View user's profile Send private message Send e-mail
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Fri Sep 01, 2006 10:28 am    Post subject: Reply with quote

Try:

Code:
proc mid {text s {n ""}} {
  if {[info exists n]} {
    return "[string range $text [expr $s - 1] [expr $n - 1]]"
  } else {
    return "[string length [string range $text [expr $s - 1] end]]"
  }
}


Not tested.
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
wiz(andrew)
Voice


Joined: 01 Sep 2006
Posts: 5

PostPosted: Fri Sep 01, 2006 12:18 pm    Post subject: Reply with quote

Thx for the help!!!
(i dont belive i missed the string section in)


http://www.tcl.tk/man/tcl8.4/TclCmd/string.htm#M40 Embarassed
thx again
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber