Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is ctoken wont work in windows version of tcl/tk

Status
Not open for further replies.

csreedhar

Programmer
Jul 31, 2003
8
IN

ctoken in windows version tcl/tk not working why? Is there any another method replacing this in windows version tcl/tk?

Could you kindly suggest me.

 
Tclx is unix specific..it was not ported to windows as it
was designed to be a unix based kit.

You could possibly emulate ctoken using upvar,regexp -indices,and string range alone if you have time to
mess with it.

Here was a preliminary try (that I just don't have the time
for) and it manipulates the given parameters(which must be variables) which is lazy and stops at the first match for each char in tok.
Hope it gives you an idea.

Code:
proc testit {StringVar Token vn} {
upvar #0 $Token tok $vn rtn
set x 0
set plen [string length $tok]

    while {$x <= $plen} {
          set pat [concat \\[string range $tok $x $x]] 
          if {[regexp -indices $pat $StringVar var]} {
               set in [string range $StringVar 0 [lindex $var 0]]
               set tok [string range $tok [expr $x + 1] $plen]
               set rtn [string range $StringVar [expr [lindex $var 0] + 1] [string length $StringVar]] ; return $in
           }
           incr x
     }
return 
}
Sample run:

set mystr
hjdiksd*&njdjkkdsuerunm&%mjdkk:)
(mars) 88 % set tok
(mars) 89 % set tok &quot;*(&quot;
*(
(mars) 90 % testit $mystr tok rtl
hjdiksd*
(mars) 91 % set rtl
&njdjkkdsuerunm&%mjdkk:)
(mars) 92 % set tok
(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top