[GRASS5] Need help with tcltk regexp

I'm trying to add a button bar to the GIS Manager with buttons to
start/select display monitors. I've got it most of it done, but have hit a
wall in a relatively simple test of whether or not a monitor is open and
selected. I've used as a model, the procedure in d.m.tcl for the display
button (which will display in the current monitor, and which while open
monitor x0 if no monitor is open and selected).

Here is my procedure. I hope someone can tell me why it is not working. I
can't get it to recognize either of the regexp clauses. The variable mon can
be set to values of x0, x1, x2, etc.

Thanks in advance.

Michael

==========================================

proc DmMonitorsel::displmon { mon } {
    global dmpath
    if ![catch {open "|d.mon -L" r} input] {
        while {[gets $input line] >= 0} {
            if {[regexp -nocase {$mon.*not running} $line buffer monitor]} {
                run "d.mon start=$mon"
                return
            } elseif {[regexp -nocase {$mon.*running} $line buffer monitor]}
{
                run "d.mon select=$mon"
                return
            } else {
                return
            }
        }
    }
}

=========================================

____________________
C. Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
PO Box 872402
Arizona State University
Tempe, AZ 85287-2402
USA

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

As per my query below, I finally figured it out.

The GIS Manger in GRASS 6.0.1 can now have buttons to launch/select display
monitors.
____________________
C. Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
PO Box 872402
Arizona State University
Tempe, AZ 85287-2402
USA

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

------ Forwarded Message

From: Michael Barton <michael.barton@asu.edu>
Date: Sat, 12 Feb 2005 23:38:24 -0700
To: grass devel <grass5@grass.itc.it>
Subject: Need help with tcltk regexp

I'm trying to add a button bar to the GIS Manager with buttons to start/select
display monitors. I've got it most of it done, but have hit a wall in a
relatively simple test of whether or not a monitor is open and selected. I've
used as a model, the procedure in d.m.tcl for the display button (which will
display in the current monitor, and which while open monitor x0 if no monitor
is open and selected).

Here is my procedure. I hope someone can tell me why it is not working. I
can't get it to recognize either of the regexp clauses. The variable mon can
be set to values of x0, x1, x2, etc.

Thanks in advance.

Michael

==========================================

proc DmMonitorsel::displmon { mon } {
    global dmpath
    if ![catch {open "|d.mon -L" r} input] {
        while {[gets $input line] >= 0} {
            if {[regexp -nocase {$mon.*not running} $line buffer monitor]} {
                run "d.mon start=$mon"
                return
            } elseif {[regexp -nocase {$mon.*running} $line buffer monitor]} {
                run "d.mon select=$mon"
                return
            } else {
                return
            }
        }
    }
}

=========================================

____________________
C. Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
PO Box 872402
Arizona State University
Tempe, AZ 85287-2402
USA

Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>

------ End of Forwarded Message

Michael Barton wrote:

Here is my procedure. I hope someone can tell me why it is not working. I
can't get it to recognize either of the regexp clauses. The variable mon can
be set to values of x0, x1, x2, etc.

            if {[regexp -nocase {$mon.*not running} $line buffer monitor]} {

The $mon won't be expanded; use quotes instead of braces, i.e.

              if {[regexp -nocase "$mon.*not running" $line buffer monitor]} {

--
Glynn Clements <glynn@gclements.plus.com>