Advertisement
DoctorD90

EmptyVar.tcl

Apr 16th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.79 KB | None | 0 0
  1. ### EmptyVar.tcl 1.2.3 MfFd8Fqd
  2.  
  3. #REQUIREMENTS
  4. # PBinScr.tcl link
  5.  
  6. #LICENSE
  7. # Copyright © 2013 Alberto Dietze "DoctorD90"
  8. #
  9. #    This program is free software: you can redistribute it and/or modify
  10. #    it under the terms of the GNU General Public License as published by
  11. #    the Free Software Foundation, either version 3 of the License, or
  12. #    (at your option) any later version.
  13. #
  14. #    This program is distributed in the hope that it will be useful,
  15. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. #    GNU General Public License for more details.
  18. #
  19. #    You should have received a copy of the GNU General Public License
  20. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
  23.  
  24. #PATERNITY
  25. #Coder: DoctorD90
  26. #Network: irc.OnlineGamesNet.net
  27. #Chan: #eHito
  28. #Mail: DoctorD90@EggTcl.tk
  29.  
  30. #PURPOSE
  31. #Check if variable is empty
  32.  
  33. #USAGE
  34. #Put in your proc:
  35. #-If var is string:
  36. #  if {[nullstring $var]} { your proc }
  37. #-If var is list
  38. #  if {[nulllist $var]} { your proc }
  39.  
  40.  
  41. ### DON'T EDIT ANYTHING BELOW ###
  42.  
  43. proc nullstring {var} {
  44.   if {![string length [string trim $var]]} {
  45.   } else {
  46.     return 1
  47.   }
  48.     return 0
  49. }
  50.  
  51. proc nulllist {var} {
  52.   if {![llength $var]} {
  53.     return 1
  54.   } else {
  55.     return 0
  56.   }
  57. }
  58.  
  59. proc nullvar {var} {
  60.   if {[info is list $var] && ![llength $var]} {
  61.     set s 1
  62.   } elseif {![info is list $var] && ![string length [string trim $var]]} {
  63.     set s 1
  64.   } else {
  65.     set s 0
  66.   }
  67.   return $s
  68. }
  69.  
  70. # if {[string is list -strict $str]} { # it's a list } elseif {[string is string -strict $str]} { # it's a string } else { # it's a something else }
  71.  
  72. ###
  73. putlog "EmptyVar.tcl LOADED"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement