home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HaCKeRz KrOnIcKLeZ 3
/
HaCKeRz_KrOnIcKLeZ.iso
/
scriptz
/
gutils.tcl
< prev
next >
Wrap
Text File
|
1996-04-23
|
1KB
|
61 lines
# gutils.tcl by Gord-@saFyre 1 March 1996
# some useful function processes:
#
# isinteger <arg> returns 1 if <arg> is
# an integer, 0 if it is not
#
# isalpha <arg> returns 1 if <arg> is
# purely alphabetical, 0 if it is not
#
# isalphanum <arg> returns 1 if <arg> is
# alphanumeric, 0 if it is not
#
# firstpunct <arg> returns the index of the
# first clause/sentence-terminating
# punctuation mark in string <arg>
set punctuation {"." ";" "!" "?" " - "}
proc isinteger {arg} {
if {[string length $arg] == 0} {return 0}
set ctr 0
while {$ctr < [string length $arg]} {
if {![string match \[0-9\] [string index $arg $ctr]]} {return 0}
set ctr [expr $ctr + 1]
}
return 1
}
proc isalpha {arg} {
if {[string length $arg] == 0} {return 0}
set ctr 0
while {$ctr < [string length $arg]} {
if {![string match \[a-zA-Z\] [string index $arg $ctr]]} {return 0}
set ctr [expr $ctr + 1]
}
return 1
}
proc isalphanum {arg} {
if {[string length $arg] == 0} {return 0}
set ctr 0
while {$ctr < [string length $arg]} {
if {![string match \[0-9a-zA-Z\] [string index $arg $ctr]]} {return 0}
set ctr [expr $ctr + 1]
}
return 1
}
proc firstpunct {arg} {
global punctuation
set response -1
foreach mark $punctuation {
set index [string first $mark $arg]
if {($index != -1) && (($index < $response) || ($response == -1))} {
set response $index
}
}
return $response
}