Reputation: 5877
I am trying to append a file name to a project directory in TCL:
set filename hello
set currentPath "D:/TEMP/project name/subfolder/"
puts [append $currentPath $filename]
According to the docs all that is needed is a varName
to which we are appending and a ?value
which is getting appended to varName
. Unfortunately when I run the above code I only get hello
as output. How can I perform this simple task on TCL?
Upvotes: 1
Views: 1574
Reputation: 137567
The problem is that you're using the variable value where you need the variable name. In Tcl (as opposed to some other languages), the $
means “read this variable now” and that's meaning that you're giving a rather odd variable name to append
. Try switching from:
puts [append $currentPath $filename]
to:
puts [append currentPath $filename]
# Be aware that this *updates* the currentPath variable
Also, if you're using this to make a filename, do consider using file join
instead; it handles all sorts of tricky cases you're not currently aware of so that you don't ever need to become aware of them.
puts [file join $currentPath $filename]
Upvotes: 2