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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new strings from text widget

Status
Not open for further replies.

reggler

Programmer
Nov 13, 2008
63
0
0
CA
Hi there,

I would like to extract content from a text widget into a string from a certain point on this means from a the point after a certain line had appeared.How do I go about that? I can't figure out how i can get the current length and then only extract the content from current length on. I put this bit of code together trying to display what I'm looking for:
Code:
    set rslt -1
    while {$rslt == -1}  {
        set str [.serialMon.cons get 0.0 end]     ;#load content from console window into $str        
        set rslt [string first "Pass: 10" $str]   ;#search for the string "Pass: 10" in $str
        if {$str != -1} {                         ;#When we found "Pass: 10" in the string
            while {!$NewStr}
            #load all the new content from .serialMon.cons from into a different string
            #but we don't want to have the old stuff
            regexp {\W\W\w\w\W\W\w\w\s\W\s\W\W\w\w\W\W\w\w\s\W\s} $NewStr exp
        }
        
        #.serialMon.cons insert end "\n------------- $exp\n"
        finaltest::delay 1000
    }

Thank you for any help or suggestions!

Ron
 
Hoops, the second while loop should look like this:
Code:
while {!$exp}{
            #load all the new content from .serialMon.cons from into a different string
            #but we don't want to have the old stuff
            regexp {\W\W\w\w\W\W\w\w\s\W\s\W\W\w\w\W\W\w\w\s\W\s} $NewStr exp
            }
 
if {$str != -1}
If I follow your logic, I think you mean
Code:
if {$[red]rslt[/red] != -1}

I don't understand what you're trying to do after you discover "pass 10". $rslt is then an index in $str. All the string data after that is
string range $str $rslt end

_________________
Bob Rashkin
 
nevermind, I've straighted this problem out, ... thanks anyways for checking back! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top