DoctorD90

EmptyVar.tcl

Apr 16th, 2013
296
0
Never
1
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.  
  29. #PURPOSE
  30. #Check if variable is empty
  31.  
  32. #USAGE
  33. #Put in your proc:
  34. #-If var is string:
  35. #  if {[nullstring $var]} { your proc }
  36. #-If var is list
  37. #  if {[nulllist $var]} { your proc }
  38.  
  39.  
  40. ### DON'T EDIT ANYTHING BELOW ###
  41.  
  42. proc nullstring {var} {
  43.   if {![string length [string trim $var]]} {
  44.   } else {
  45.     return 1
  46.   }
  47.     return 0
  48. }
  49.  
  50. proc nulllist {var} {
  51.   if {![llength $var]} {
  52.     return 1
  53.   } else {
  54.     return 0
  55.   }
  56. }
  57.  
  58. proc nullvar {var} {
  59.   if {[info is list $var] && ![llength $var]} {
  60.     set s 1
  61.   } elseif {![info is list $var] && ![string length [string trim $var]]} {
  62.     set s 1
  63.   } else {
  64.     set s 0
  65.   }
  66.   return $s
  67. }
  68.  
  69. # 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 }
  70.  
  71. ###
  72. putlog "EmptyVar.tcl LOADED"
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment