puts "Hello World!"
set global-var 100
set son "peter pan"
proc testing {arg1 arg2} {
# body :start
set i 11
puts [info locals]
puts [info proc testing]
puts "$arg1 $arg2"
puts "bye"
#body:end
}
testing 4 hshs
puts [info args testing]
puts [info body testing]
puts [info cmdcount]
puts [info commands]
puts [info commands puts]
puts [info globals]
puts [info globals global-var]
puts [info tclversion]
puts [info vars]
puts [info vars son]
puts [info hostname]
puts [info proc testing]
puts [info exists soninlaw]
puts [info exists son]
puts [info args testing]
-prints all the argument names of a procedure
% arg1 arg2
puts [info body testing]
-prints the body of the procedure.
% # body :start
set i 11
puts [info locals]
puts [info proc testing]
puts "$arg1 $arg2"
puts "bye"
#body:end
puts [info cmdcount]
-returns a count of the total number of commands that have been invoked in this interpreter.
% 97
puts [info commands]
-returns a list of names of all the Tcl commands in the current namespace, including both the built-in commands and the command procedures defined using the proc command.
%tell socket subst open eof pwd glob list pid exec testing auto_load_index time unknown eval lassign lrange fblocked lsearch auto_import gets case lappend proc break variable llength auto_execok return linsert error catch clock info split array if fconfigure concat join lreplace source fcopy global switch auto_qualify update close cd for auto_load file append lreverse format unload read package set binary namespace scan apply trace seek while chan flush after vwait dict continue uplevel foreach lset rename fileevent regexp lrepeat upvar encoding expr unset load regsub interp exit puts incr lindex lsort tclLog string
puts [info commands puts]
- returns tcl specific commands by pattern matching.If not matched null is returned.
% puts
puts [info globals]
- returns a list of all the names of currently defined global variables.
% tcl_rcFileName tcl_version argv0 argv tcl_interactive auto_path son env tcl_pkgPath tcl_patchLevel argc global-var tcl_library tcl_platf
puts [info globals global-var]
- search for specific global variable by pattern matching.
% global-var
puts [info tclversion]
- displays the current tcl version number.
% 8.5
puts [info vars]
- returns a list of all the names of currently visible variables.
% tcl_rcFileName tcl_version argv0 argv tcl_interactive auto_path son env tcl_pkgPath tcl_patchLevel argc global-var tcl_library tcl_platf
puts [info vars son]
- returns a specific variable if pattern is matched otherwise null.
% son
puts [info hostname]
- returns the hostname.
puts [info proc testing]
- returns the procedure name if it exists else null.
% testing
puts [info locals]
- returns all the local variables including procedure args.
% arg1 arg2 i
puts [info exists soninlaw]
- if the variable (local or global) doesn't exists then return 0
% 0
puts [info exists son]
- if the variable (local or global) exists then return 1.
% 1
info level :
returns the stack level of invoking procedure.
proc t2 {} {
puts "stack Level => [info level]"
}
proc t1 {} {
puts "stack Level => [info level]"
t2
}
#main#
puts "Main => [info level]"
t1
#main#
output :
% Main => 0
stack Level => 1
stack Level => 2
No comments:
Post a Comment