home *** CD-ROM | disk | FTP | other *** search
/ Internet File Formats / InternetFileFormatsCD.bin / text / latex / mac / alpha60.hqx / Tcl / SystemCode / misc.tcl < prev    next >
Encoding:
Text File  |  1995-07-16  |  17.1 KB  |  703 lines

  1. #===========================================================================
  2. # Information about a selection or window.
  3. #===========================================================================
  4. proc wordCount {} {
  5.     if {[set chars [expr {[selEnd] - [getPos]}]]} {
  6.         set lines [expr {[lindex [posToRowCol [selEnd]] 0] - [lindex [posToRowCol [getPos]] 0]}]
  7.         set text [getSelect]
  8.     } else {
  9.         set chars [maxPos]
  10.         set lines [lindex [posToRowCol $chars] 0]
  11.         set text [getText 0 [maxPos]]
  12.     }
  13.     if {[regsub -all {[!=;.,\(\#\=\):\{\"\}]} $text " " ret]} {
  14.         set words [llength $ret]
  15.     } else {
  16.         set words [llength $text]
  17.     }
  18.     alertnote [format "%d chars, %d words, %d lines" $chars $words $lines]
  19. }
  20.  
  21. # proc matchingLines {} {
  22. #     if [catch {prompt "Regular expression:" ""} reg] return
  23. #     if {![string length $reg]} return
  24. #     set reg ^.*$reg.*$
  25. #     set pos [getPos]
  26. #     set matches 0
  27. #     while {![catch {search -f 1 -r 1 -m 0 -i 1 $reg $pos} mtch]} {
  28. #         append lines "\r" [format "%4d: " [lindex [posToRowCol [lindex $mtch 0]] 0]] [eval getText $mtch]
  29. #         set pos [lindex $mtch 1]
  30. #         incr matches
  31. #     }
  32. #     new
  33. #     insertText [format "%d matching lines\r-----" $matches] $lines "\r"
  34. # }
  35. set lastMatchingLines ""
  36.  
  37. proc matchingLines {} {
  38.     global lastMatchingLines
  39.     
  40.     if [catch {prompt "Regular expression:" $lastMatchingLines} reg] return
  41.     set lastMatchingLines $reg
  42.     if {![string length $reg]} return
  43.     set reg ^.*$reg.*$
  44.     set pos 0
  45.     set fileName [lindex [winNames -f] 0]
  46.     set matches 0
  47.     while {![catch {search -s -f 1 -r 1 -m 0 -i 1 $reg $pos} mtch]} {
  48.         append lines "\r" [format "Line %d: " [lindex [posToRowCol [lindex $mtch 0]] 0]] [eval getText $mtch] "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t░$fileName"
  49.         set pos [lindex $mtch 1]
  50.         incr matches
  51.     }
  52.     new -n {* Matching Lines *}
  53.     insertText [format "%d matching lines (<cr> to go to match)\r-----" $matches] $lines "\r"
  54.     select [nextLineStart [nextLineStart 0]] [nextLineStart [nextLineStart [nextLineStart 0]]]
  55.     
  56.     global winModes
  57.     set name [lindex [winNames] 0]
  58.     changeMode [set winModes($name) Brws]
  59.     setWinInfo dirty 0
  60.     setWinInfo read-only 1
  61.     
  62.     shrinkWindow
  63. }
  64.  
  65. #=============================================================================
  66. # Random functions.
  67. #=============================================================================
  68.  
  69. #***********************************************************************
  70. #                                                                      *
  71. #   Comment box and uncomment box courtesy of Igor Mikolic-Torreira.   *
  72. #                                                                      *
  73. #**********************************************************************/
  74.  
  75. proc commentBox {} {
  76.  
  77. # Preliminaries
  78.  
  79.     if {[getPos] == [selEnd]} {
  80.         alertnote "Must select region to be commented."
  81.         return
  82.     }
  83.     global mode
  84.     watchCursor
  85.     
  86. # Set what the comment block will look like
  87.  
  88.     case $mode in {
  89.         "Bib TeX" {
  90.             set begComment "%"
  91.             set begComLen 1
  92.             set endComment "%"
  93.             set endComLen 1
  94.             set fillChar "%"
  95.             set spaceOffset 3
  96.         }
  97.         "Text" {
  98.             set begComment "!"
  99.             set begComLen 1
  100.             set endComment "!"
  101.             set endComLen 1
  102.             set fillChar "!"
  103.             set spaceOffset 3
  104.         }
  105.         "Fort" {
  106.             set begComment "C"
  107.             set begComLen 1
  108.             set endComment "C"
  109.             set endComLen 1
  110.             set fillChar "C"
  111.             set spaceOffset 3
  112.         }
  113.         "Tcl" {
  114.             set begComment "#"
  115.             set begComLen 1
  116.             set endComment "#"
  117.             set endComLen 1
  118.             set fillChar "#"
  119.             set spaceOffset 3
  120.         }
  121.         "C C++" {
  122.             set begComment "/*"
  123.             set begComLen 2
  124.             set endComment "*/"
  125.             set endComLen 2
  126.             set fillChar "*"
  127.             set spaceOffset 3
  128.         }
  129.         default {
  130.             alertnote "I don't know what comments should look like in this mode.  Sorry."
  131.             return
  132.         }
  133.     }
  134.     set aSpace " "
  135.  
  136. # First make sure we grab a full block of lines and adjust highlight
  137.  
  138.     set start [getPos]
  139.     set start [lineStart $start]
  140.     set end [selEnd]
  141.     set end [nextLineStart [expr $end-1]]
  142.     select $start $end
  143.  
  144. # Now get rid of any tabs
  145.     
  146.     if { $end < [maxPos] } then {
  147.         createTMark stopComment [expr $end+1]
  148.         tabsToSpaces
  149.         gotoTMark stopComment
  150.         set end [expr [getPos]-1]
  151.         removeTMark stopComment
  152.     } else {
  153.         tabsToSpaces
  154.         set end [maxPos]
  155.     }
  156.     select $start $end
  157.     set text [getText $start $end]
  158.     
  159. # Next turn it into a list of lines--possibly drop an empty 'last line'
  160.  
  161.     set lineList [split $text "\r"]
  162.     set emptyLine [lsearch $lineList {}]
  163.     if { $emptyLine != -1 } then {
  164.         set numLines [llength $lineList]
  165.         set lineList [lrange $lineList 0 [expr $numLines-2]]
  166.     }
  167.     set numLines [llength $lineList]
  168.     
  169. # Find the longest line length and determine the new line length
  170.  
  171.     set maxLength 0
  172.     foreach thisLine $lineList {
  173.         set thisLength [string length $thisLine]
  174.         if { $thisLength > $maxLength } then { 
  175.             set maxLength $thisLength 
  176.         }
  177.     }
  178.     set newLength [expr {$maxLength + 2 + 2*$spaceOffset}]
  179.     
  180. # Now create the top & bottom bars and a blank line
  181.  
  182.     set topBar $begComment
  183.     for { set i 0 } { $i < [expr {$newLength - $begComLen}] } { incr i } {
  184.         set topBar $topBar$fillChar
  185.     }
  186.     set botBar ""
  187.     for { set i 0 } { $i < [expr {$newLength - $endComLen}] } { incr i } {
  188.         set botBar $botBar$fillChar
  189.     }
  190.     set botBar $botBar$endComment
  191.     set blankLine $fillChar
  192.     for { set i 0 } { $i < [expr {$newLength - 2}] } { incr i } {
  193.         set blankLine $blankLine$aSpace
  194.     }
  195.     set blankLine $blankLine$fillChar
  196.     
  197. # For each line add stuff on left and spaces and stuff on right for box sides
  198. # and concatenate everything into 'text'.  Start with topBar; end with botBar
  199.  
  200.     set text $topBar\r$blankLine\r
  201.     
  202.     set frontStuff $fillChar
  203.     set backStuff $fillChar
  204.     for { set i 0 } { $i < $spaceOffset } { incr i } {
  205.         set frontStuff $frontStuff$aSpace  
  206.         set backStuff $aSpace$backStuff
  207.     }
  208.     set backStuffLen [string length $backStuff]
  209.     
  210.     for { set i 0 } { $i < $numLines } { incr i } {
  211.         set thisLine [lindex $lineList $i ]
  212.         set thisLine $frontStuff$thisLine
  213.         set thisLength [string length $thisLine]
  214.         set howMuchPad [expr {$newLength - $thisLength - $backStuffLen}]
  215.         for { set j 0 } { $j < $howMuchPad } { incr j } {
  216.             set thisLine $thisLine$aSpace 
  217.         }
  218.         set thisLine $thisLine$backStuff
  219.         set text $text$thisLine\r
  220.     }
  221.     
  222.     set text $text$blankLine\r$botBar\r
  223.     
  224. # Now replace the old stuff, turn spaces to tabs, and highlight
  225.  
  226.     replaceText    $start $end    $text
  227.     set end [expr {$start+[string length $text]}]
  228.     createTMark stopComment [expr $end+1]
  229.     select $start $end
  230.     spacesToTabs
  231.     gotoTMark stopComment
  232.     set end [expr [getPos]-1]
  233.     removeTMark stopComment
  234.     select $start $end
  235. }
  236.  
  237.  
  238.  
  239. proc uncommentBox {} {
  240.  
  241. # Preliminaries
  242.  
  243.     if {[getPos] == [selEnd]} {
  244.         alertnote "Must select region to be uncommented."
  245.         return
  246.     }
  247.     global mode
  248.     watchCursor
  249.     
  250. # Set what the comment block will look like
  251.  
  252.     case $mode in {
  253.         "Bib TeX" {
  254.             set begComment "%"
  255.             set begComLen 1
  256.             set endComment "%"
  257.             set endComLen 1
  258.             set fillChar "%"
  259.             set spaceOffset 3
  260.         }
  261.         "Text" {
  262.             set begComment "!"
  263.             set begComLen 1
  264.             set endComment "!"
  265.             set endComLen 1
  266.             set fillChar "!"
  267.             set spaceOffset 3
  268.         }
  269.         "Fort" {
  270.             set begComment "C"
  271.             set begComLen 1
  272.             set endComment "C"
  273.             set endComLen 1
  274.             set fillChar "C"
  275.             set spaceOffset 3
  276.         }
  277.         "Tcl" {
  278.             set begComment "#"
  279.             set begComLen 1
  280.             set endComment "#"
  281.             set endComLen 1
  282.             set fillChar "#"
  283.             set spaceOffset 3
  284.         }
  285.         "C C++" {
  286.             set begComment "/*"
  287.             set begComLen 2
  288.             set endComment "*/"
  289.             set endComLen 2
  290.             set fillChar "*"
  291.             set spaceOffset 3
  292.         }
  293.         default {
  294.             alertnote "I don't know what comments should look like in this mode.  Sorry."
  295.             return
  296.         }
  297.     }
  298.     set aSpace " "
  299.     set aTab \t
  300.  
  301. # First make sure we grab a full block of lines
  302.  
  303.     set start [getPos]
  304.     set start [lineStart $start]
  305.     set end [selEnd]
  306.     set end [nextLineStart [expr $end-1]]
  307.     set text [getText $start $end]
  308.  
  309. # Make sure we're at the start and end of the box
  310.  
  311.     set startOK [string first $begComment $text]
  312.     set endOK [string last $endComment $text]
  313.     set textLength [string length $text]
  314.     if { $startOK != 0 || ($endOK != [expr {$textLength-$endComLen-1}] || $endOK == -1) } then {
  315.         alertnote "You must highlight the entire comment box, including the borders."
  316.         return
  317.     }
  318.     
  319. # Now get rid of any tabs
  320.     
  321.     if { $end < [maxPos] } then {
  322.         createTMark stopComment [expr $end+1]
  323.         tabsToSpaces
  324.         gotoTMark stopComment
  325.         set end [expr [getPos]-1]
  326.         removeTMark stopComment
  327.     } else {
  328.         tabsToSpaces
  329.         set end [maxPos]
  330.     }
  331.     select $start $end
  332.     set text [getText $start $end]
  333.     
  334. # Next turn it into a list of lines--possibly drop an empty 'last line'
  335.  
  336.     set lineList [split $text "\r"]
  337.     set emptyLine [lsearch $lineList {}]
  338.     if { $emptyLine != -1 } then {
  339.         set numLines [llength $lineList]
  340.         set lineList [lrange $lineList 0 [expr $numLines-2]]
  341.     }
  342.     set numLines [llength $lineList]
  343.     
  344. # Delete the first and last lines, recompute number of lines
  345.  
  346.     set lineList [lreplace $lineList [expr $numLines-1] [expr $numLines-1] ]
  347.     set lineList [lreplace $lineList 0 0 ]
  348.     set numLines [llength $lineList]
  349.     
  350. # Eliminate 2nd and 2nd-to-last lines if they are empty
  351.  
  352.     set eliminate $fillChar$aSpace$aTab
  353.     set thisLine [lindex $lineList [expr $numLines-1]]
  354.     set thisLine [string trim $thisLine $eliminate]
  355.     if { [string length $thisLine] == 0 } then {
  356.         set lineList [lreplace $lineList [expr $numLines-1] [expr $numLines-1] ]
  357.     }
  358.     set thisLine [lindex $lineList 0]
  359.     set thisLine [string trim $thisLine $eliminate]
  360.     if { [string length $thisLine] == 0 } then {
  361.         set lineList [lreplace $lineList 0 0 ]
  362.     }
  363.     set numLines [llength $lineList]    
  364.     
  365. # For each line trim stuff on left and spaces and stuff on right and splice
  366.  
  367.     set dropFromLeft [expr $spaceOffset+1]
  368.     set text ""
  369.     for { set i 0 } { $i < $numLines } { incr i } {
  370.         set thisLine [lindex $lineList $i]
  371.         set thisLine [string trimright $thisLine $eliminate]
  372.         set thisLine [string range $thisLine $dropFromLeft end]
  373.         set text $text$thisLine\r
  374.     }
  375.         
  376. # Now replace the old stuff, convert spaces back to tabs
  377.  
  378.     replaceText    $start $end    $text
  379.     set end [expr {$start+[string    length $text]}]
  380.     createTMark stopComment [expr $end+1]
  381.     select $start $end
  382.     spacesToTabs
  383.     gotoTMark stopComment
  384.     set end [expr [getPos]-1]
  385.     removeTMark stopComment
  386.     select $start $end
  387. }
  388.  
  389.  
  390. #================================================================================
  391.  
  392. proc nextFunc {} {
  393.     searchFunc 1
  394. }
  395.  
  396. proc prevFunc {} {
  397.     searchFunc 0
  398. }
  399.  
  400. proc searchFunc {dir} {
  401.     global funcExpr
  402.     set pos [getPos]
  403.     select $pos
  404.     if ($dir==1) {
  405.         incr pos
  406.     } else {
  407.         set pos [expr $pos-1]
  408.     }
  409.     if {![catch {search -s -f $dir -i 1 -r 1 $funcExpr $pos} res]} {
  410.         eval select $res
  411.     }
  412. }
  413.  
  414. #===========================================================================
  415. # Comment routines.
  416. #===========================================================================
  417. proc commentPara {} {
  418. }
  419.  
  420.  
  421.  
  422. #===========================================================================
  423. # Sorting the selection.
  424. # AUTHOR: David C. Black     black@mpd.tandem.com
  425. #===========================================================================
  426. proc sortLines {} {
  427.     set ends [getEndpts]
  428.     set start [lindex $ends 0]
  429.     set end  [lindex $ends 1]
  430.     if {$start == $end} {
  431.         alertnote "You must highlight the section you wish to sort."
  432.         return
  433.     }
  434.     if {[lookAt [expr $end-1]] != "\r"} {
  435.         alertnote "The selection must consist only of complete lines."
  436.         return
  437.     }
  438.     set text [getText $start [expr {$end-1}]]
  439.     set text [join [lsort [split $text "\r"]] "\r"]
  440.     replaceText $start [expr {$end-1}] $text
  441.     select $start $end
  442. }
  443.  
  444.  
  445.  
  446. #===========================================================================
  447. # Dump all current settings into a file.
  448. #===========================================================================
  449. proc insertGlobalSettings {} {
  450.     uplevel #0 {
  451.         foreach var [info globals] {
  452.             if {![catch {set $var}]} {
  453.                 insertText "set " $var " \{" [set $var] "\}\r"
  454.             }
  455.         }
  456.     }
  457. }
  458.  
  459.  
  460. #================================================================================
  461. # Substitute global variables in possibly nested list.
  462. #================================================================================
  463. proc subVars {words} {
  464.     global silly
  465.     global a
  466.     set silly $words
  467.     set out {}
  468.     foreach a $words {
  469.         if {[llength $a] == 1} {
  470.             lappend out [uplevel #0 {eval set x $a}]
  471.         } else {
  472.             lappend out [subVars $a]
  473.         }
  474.     }
  475.     return $out
  476. }
  477.  
  478. #================================================================================
  479. # Block shift left and right.
  480. #================================================================================
  481.  
  482. proc shiftLeft {} {
  483.     global shiftChar
  484.     doShiftLeft "\t"
  485.     
  486. }
  487. proc shiftLeftSpace {} {
  488.     global shiftChar
  489.     doShiftLeft " "
  490. }
  491.  
  492. proc doShiftLeft {shiftChar} {
  493.      set start [lineStart [getPos]]
  494.      set end [nextLineStart [expr [selEnd] - 1]]
  495.     if {$start >= $end} {set end [nextLineStart $start]}
  496.     
  497.     set text [split [getText $start [expr $end - 1]] "\r"]
  498.     
  499.     set textout ""
  500.     
  501.     foreach line $text {
  502.         if {[string index $line 0] == $shiftChar} {
  503.             lappend textout [string range $line 1 end]
  504.         } else {
  505.             lappend textout $line
  506.         }
  507.     }
  508.  
  509.     set text [join $textout "\r"]    
  510.     replaceText $start [expr $end - 1] $text
  511.     select $start [expr 1 + $start + [string length $text]]
  512. }
  513.  
  514.  
  515. proc shiftRight {} {
  516.     global shiftChar
  517.     doShiftRight "\t"
  518.     
  519. }
  520. proc shiftRightSpace {} {
  521.     global shiftChar
  522.     doShiftRight " "
  523. }
  524. proc doShiftRight {shiftChar} {
  525.     set start [lineStart [getPos]]
  526.     set end [nextLineStart [expr [selEnd] - 1]]
  527.     if {$start >= $end} {set end [nextLineStart $start]}
  528.     
  529.     set text [split [getText $start [expr $end - 1]] "\r"]
  530.     
  531.     set textout ""
  532.     
  533.     foreach line $text {
  534.         lappend textout $shiftChar$line
  535.     }
  536.     
  537.     set text [join $textout "\r"]    
  538.     replaceText $start [expr $end - 1] $text
  539.     select $start [expr 1 + $start + [string length $text]]
  540. }
  541.  
  542.  
  543.  
  544. # rglobText [option list] dir pat
  545. # 'dir' should be a properly formed directory, ending w/ a ':'. 'pat' should be 
  546. # a simple pattern w/ no directory specifications (i.e. "*.c").
  547. proc rglobText {optlist dir pat} {
  548.  
  549.     message "$dir"
  550.     set cmd [concat glob -t TEXT $optlist]
  551.     lappend cmd $dir$pat
  552.     if {[catch {eval $cmd} files]} {
  553.         set files ""
  554.     }
  555.     
  556.     if {![catch {glob $dir*} all]} {
  557.         foreach f $all {
  558.             if {[file isdir $f]} {
  559.                 set files [concat $files [rglobText $optlist $f: $pat]]
  560.             }
  561.         }
  562.     }
  563.     return $files
  564. }
  565.  
  566.  
  567. proc switchApp {} {
  568.     set procs ""
  569.     foreach p [processes] {
  570.         lappend procs [lindex $p 0]
  571.     }
  572.     set to [listpick -p "Switch to app:" [lsort $procs]]
  573.     if {[string length $to]} {
  574.         switchTo $to
  575.     }
  576. }
  577.  
  578.  
  579. proc selectAll {} {
  580.     select 0 [maxPos]
  581. }
  582.  
  583.  
  584. proc twiddle {} {
  585.     set pos [getPos]
  586.     if {!$pos || ($pos == [maxPos])} return;
  587.     if {[string length [set text [getSelect]]]} {
  588.         if {[string length $text] == 1} {
  589.             return
  590.         } else {
  591.             set sel [expr [selEnd] - 1]
  592.             set one [lookAt $sel]
  593.             set two [lookAt $pos]
  594.             replaceText $pos [expr $sel + 1] "$one[getText [expr $pos+1] $sel]$two"
  595.             select $pos [expr $sel+1]
  596.             return
  597.         }
  598.     }
  599.     set one [lookAt $pos]
  600.     set two [lookAt [expr $pos-1]]
  601.     replaceText [expr $pos-1] [expr $pos + 1] "$one$two"
  602.     select  [expr $pos-1] [expr $pos + 1]
  603. }
  604.  
  605. proc twiddleWords {} {
  606.     global wordBreakPreface wordBreak
  607.  
  608.     if {[getPos] != [selEnd]} {
  609.         set start1 [getPos]; set end2 [selEnd]
  610.         select $start1
  611.         forwardWord; set end1 [getPos]
  612.         goto $end2
  613.         backwardWord; set start2 [getPos]
  614.     } else {
  615.         select [set pos [getPos]]
  616.         backwardWord; set start1 [getPos]
  617.         forwardWord; set end1 [getPos]
  618.         goto $pos
  619.         forwardWord; set end2 [getPos]
  620.         backwardWord; set start2 [getPos]
  621.     }        
  622.  
  623.     if {$start1 != $start2} {
  624.         set mid [getText $end1 $start2]
  625.         replaceText $start1 $end2 "[getText $start2 $end2]$mid[getText $start1 $end1]"
  626.         select $start1 $end2
  627.     }
  628. }
  629.  
  630. #================================================================================
  631. # Print a window using John Cho's Enscriptor (A text file printing app that
  632. # works like Adobe Enscript.)
  633. #
  634.  
  635. proc setupPrintMenu {} {
  636.     global pathComments defaultPrinter modifiedVars
  637.     if {![info exists defaultPrinter]} {
  638.         set defaultPrinter "Alpha"
  639.         lappend modifiedVars defaultPrinter
  640.     }
  641.     set m [list {/P<SPrint╔} {/P<S<I<OPrint All╔} {(-} Alpha $pathComments(kodexPath) $pathComments(enscriptorPath) $pathComments(droppsPath)]
  642.     menu -m -n print -p printProc $m
  643.     
  644.     foreach item $m {
  645.         if {$item == $defaultPrinter} {
  646.             markMenuItem -m print $item on
  647.         } else {
  648.             markMenuItem -m print $item off
  649.         }
  650.     }
  651. }
  652.  
  653. proc printProc {menu item} {
  654.     global modifiedVars defaultPrinter pathComments
  655.     switch -glob $item {
  656.         "Print All"        {    if {$defaultPrinter == "Alpha"} {
  657.                                 printAll
  658.                             } else {
  659.                                 foreach f [winNames -f] {
  660.                                     printFile $f
  661.                                 }
  662.                             }
  663.                         }
  664.         "Print"            {printFile [lindex [winNames -f] 0]}
  665.         "Alpha"            {set defaultPrinter "Alpha"; lappend modifiedVars defaultPrinter; setupPrintMenu}
  666.         "Kodex*"        {set defaultPrinter $pathComments(kodexPath); lappend modifiedVars defaultPrinter; setupPrintMenu}
  667.         "Enscr*"        {set defaultPrinter $pathComments(enscriptorPath); lappend modifiedVars defaultPrinter; setupPrintMenu}
  668.         "Send*"            {set defaultPrinter $pathComments(droppsPath); lappend modifiedVars defaultPrinter; setupPrintMenu}
  669.     }
  670. }
  671.  
  672.  
  673. proc printFile {fname} {
  674.     global defaultPrinter
  675.     
  676.     switch -glob $defaultPrinter {
  677.         "Alpha"            {print}
  678.         "Kodex*"        {openAndSendFile $fname kodexPath Kodex KoDX}
  679.         "Enscr*"        {openAndSendFile $fname enscriptorPath Enscriptor Ens3}
  680.         "Send*"            {openAndSendFile $fname droppsPath {DropÑPS} {DÑPS}}
  681.     }
  682. }
  683.  
  684.  
  685. proc openAndSendFile {fname path name sig} {
  686.     global $path
  687.  
  688.     catch {checkRunning $name $sig $path} name
  689.  
  690.     if {[winDirty]} {
  691.         if {[askyesno "Save '$fname'?"] == "yes"} {
  692.             save
  693.         }
  694.     }
  695.     message "Sending to '$name'..."
  696.     if {[catch {sendOpenEvent noReply $name $fname}] } {
  697.         beep 
  698.     } else {
  699.         switchTo $name
  700.     }
  701.     message ""
  702. }
  703.