====== Getting started with Tcl: example 12 ====== This page is part of the Airplug documentation related to Tcl/Tk.\\ [[en:doc:pub:tcltk:start|Back to the Tcl/Tk documentation page]] / [[en:doc:summary|Back to the Airplug documentation page]] ===== Passing arguments using the name of the variable instead of its value ===== ==== Script ==== #!/usr/bin/tclsh set str "hello, world" puts stdout "str = $str" puts stdout "The length of \"$str\" is [string length $str]" proc display_length { s } { puts stdout " the length of \"$s\" is [string length $s]" } proc display_length_upvar { s } { upvar $s localstr puts stdout " the length of \"$localstr\" is [string length $localstr]" } puts stdout "" puts stdout "Calling display_length str" display_length str puts stdout "Calling display_length_upvar str" display_length_upvar str ==== Output ==== str = hello, world The length of "hello, world" is 12 Calling display_length str the length of "str" is 3 Calling display_length_upvar str the length of "hello, world" is 12
---- This page is part of the Airplug documentation related to Tcl/Tk.\\ [[en:doc:pub:tcltk:start|Back to the Tcl/Tk documentation page]] / [[en:doc:summary|Back to the Airplug documentation page]]