Regular expresion and updating the -state option.



Hello group,
I am writing a script in wish 8.3 and I am out of ideas here. I am horrible with regular expression. In the following script I want to select the "Start Logging" option from the file menu and get the following results:

{Adams Je|64@1882835} {Adams, Jo|1555@18008835} {Adams, Ra|80346@180025} {Adams, Wa|91439@180325} {Adkinson, T|1301@1882835}

Instead of:
{<OPTION VALUE="Adams Je|64@1882835">} {Adams Je|64@1882835} {<OPTION VALUE="Adams, Jo|1555@18008835">} {Adams, Jo|1555@18008835} {<OPTION VALUE="Adams, Ra|80346@180025">} {Adams, Ra|80346@180025} {<OPTION VALUE="Adams, Wa|91439@180325">} {Adams, Wa|91439@180325} {<OPTION VALUE="Adkinson, T|1301@1882835">} {Adkinson, T|1301@1882835}

I know that the -inline option is the one giving me the results including the <OPTION VALUE=""> string but how the heck do I get rid of it? Is it a better way to get the values I want (name and pin/pager # I will take the {} out later) with another regexp? There will be about 800 results and when I get double results, well, you know.

Then when I get the results the foo proc the "Start Logging" should be "disabled and the "Stop Logging" should be normal. I cannot get that behavior either. Eventually after I exit the proc the "Start Logging" and "Stop Logging" should reset back to the original state.

Any help will be appreciated.

Here is the modified script for testing purposes:

wm title . "TDP"
wm iconname . "TDP"
proc foo {} {
set foo2 0
while {$foo2 != 1} {
set data { <OPTION VALUE="Adams Je|64@1882835">Adams Je</OPTION>
<OPTION VALUE="Adams, Jo|1555@18008835">Adams, Jo</OPTION>
<OPTION VALUE="Adams, Ra|80346@180025">Adams, Ra</OPTION>
<OPTION VALUE="Adams, Wa|91439@180325">Adams, Wa</OPTION>
<OPTION VALUE="Adkinson, T|1301@1882835">Adkinson, Tim</OPTION>}
set users_list [regexp -all -inline -- {<OPTION VALUE="([^\>]*)">} $data]
puts $users_list
set stop_state normal
set start_state disable
incr foo2
} ; #end of while loop
#set stop_state disable
#set start_statenormal
} ; #end of foo proc
set stop_state disable
set start_state normal
frame .mbar -borderwidth 1 -relief raised
pack .mbar -fill x ;# packing for file/help menu. Must be at the top.
menubutton .mbar.file -text "File" -underline 0 -menu .mbar.file.m
set fm [menu .mbar.file.m -tearoff 0]
$fm add command -label "Start Logging" -state $start_state -underline 0 -command {foo}
$fm add command -label "Stop Logging" -state $stop_state -underline 0 -command {set foo2 1}
pack .mbar.file -side left


Thanks for the help folks!
Fernando
.



Relevant Pages

  • Modifiying the -state of a menubutton label.
    ... I am writing a script in wish 8.3 and I am trying to interactively change the state of a few menu labels. ... Basically when the script start I should have Start Logging normal and Stop Logging disable. ... Then when I get the results the foo proc the "Start Logging" should be "disabled and the "Stop Logging" should be normal. ...
    (comp.lang.tcl)
  • Re: PHP time monitor
    ... that could be solved with logging, but I haven't attempted it yet so I'm ... I had originally envisioned the idea that a script would ... certain time was reached the script would execute. ... > Scheduling is better done with OS-level scheduling facilities such ...
    (alt.php)
  • Re: logon script started twice
    ... Is it possible that the same script is defined in some other GPO as ... I would enable userenv logging, and run the Resultant Set of Policy ...
    (microsoft.public.windows.terminal_services)
  • Re: How to prevent logging warning?
    ... prevent that the script that uses the library prints ... 'No handlers could be found for logger "comtypes.client"' when the ... I would like to setup the logging so that there is no logging when ... I want the script by default to be agnostic about the libraries ...
    (comp.lang.python)
  • Re: Disappearing files, created from /etc/X11/Xclients
    ... are created by normal users, so I cannot use files for logging. ... Also there is no console because this is the /etcX11/Xclients script, e.g. it is executed by gdm after logging in to X window system through xdmpc. ... If I login with a normal user and I try to re-run /etc/X11/Xclients then the files gets created, and finally I get an error message telling that gnome is already running. ...
    (freebsd-questions)