[MG] Apr 29th 2004 - This little program (called WikiIndent, until I typoed the name when adding this page and decided to rename the program;) is extremely basic; it opens a file of your choice, then replicates in a file named 'wi'; the only difference is that each line will have a single white space added to the beginning of it. The point? When I code in Tcl, I don't put a space at the left-hand line of anything not inside a call to [proc], [if], etc (including the call to proc itself), so when I go to paste things into the Wiki, I need to add spaces to each line to have it register as Tcl code. And after writing three scripts like this in the last week, I decided to stick with one and publish it. ;) You should be able to specify the file-name on the command line, too (ie, wish wikindent.tcl ./mycode.tcl). It still needs wish, rather than tclsh, though, because it has calls to tk_messageBox. The code: # WikIndent, by Mike Griffiths, Apr 29 2004 # Put a space before every line in a (text/tcl code) file. set t WikIndent wm withdraw . set types { {{TCL Scripts} {.tcl} } {{Text Files} {.txt} } {{All Files} * } } set f [lindex $argv 0] if { $f == "" } { set f [tk_getOpenFile -filetypes $types -title "Select a Tcl Code File"] } if { $f == "" } { exit; } if { ![file exists $f] || ![file isfile $f] } { tk_messageBox -icon error -title $t -message "No such file '$f'!" } if { ![file readable $f] || [catch {open $f r} fid] } { tk_messageBox -icon error -title $t -message "Can't read file '$f': $fid" exit; } set out [file join [file dirname $f] "wi[file tail $f]"] if { [catch {open "$out" w+} fid2]} { tk_messageBox -icon error -title $t -message "Can't open output file '$out': $fid2" exit; } gets $fid str while { ![eof $fid] } { puts $fid2 " $str" gets $fid str } close $fid close $fid2 tk_messageBox -icon info -title $t -message "Done!" ---- Oh, boy. '''cat sample.txt | sed 's/^/ /' > sample2.txt''' [MG] I'm on Windows, so don't really have that option available. That's one of the main reasons I love Tcl; write some code, and almost any computer can run it, as-is, so long as you write it properly to start with. /me is on Windows too. Pick [Cygwin] or the GNU native Windows ports and another excuse. ;-) ---- [[ Category ? ]]