1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
/* Copyright (c) 1996--1999 Geoff Pike. */
/* All rights reserved. */
/* Floater is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* This software is provided "as is" and comes with absolutely no */
/* warranties. Geoff Pike is not liable for damages under any */
/* circumstances. Support is not provided. Use at your own risk. */
/* Personal, non-commercial use is allowed. Attempting to make money */
/* from Floater or products or code derived from Floater is not allowed */
/* without prior written consent from Geoff Pike. Anything that remotely */
/* involves commercialism, including (but not limited to) systems that */
/* show advertisements while being used and systems that collect */
/* information on users that is later sold or traded require prior */
/* written consent from Geoff Pike. */
//if a isn't set yet, set it to b; otherwise do nothing
proc tryset {a b} {
if {[set x [string first "(" $a]] == -1} {
global $a
} else {
global [string range $a 0 [incr x -1]]
}
if [catch {set $a}] {set $a $b}
}
//like set, but for globals
proc gset {a {b salami_on_rye}} {
if {[set x [string first "(" $a]] == -1} {
global $a
} else {
global [string range $a 0 [incr x -1]]
}
if ![string compare $b salami_on_rye] {set $a} {set $a $b}
}
//like unset, but for globals
proc gunset {a} {
if {[set x [string first "(" $a]] == -1} {
global $a
} else {
global [string range $a 0 [incr x -1]]
}
unset $a
}
|