$ getclip | gawk '{ print "convert.vbs /profile:" $1 ".cvt\ndaily.vbs /profile:" $1 ".dly\n" }' | putclip
It gets the word I put in the clipboard (selected and copied out of SciTe) and puts back on the clipboard the word as commands and filenames to be pasted back in. For example, I put
Marble_Bar
on the clipboard, reissue the command, and get
convert.vbs /profile:Marble_Bar.cvt
daily.vbs /profile:Marble_Bar.dly
Past (20 years or so) and present code. A variety of languages and platforms. Some gems. More gravel. Some useful stuff and some examples of how not to do it.
Showing posts with label gawk. Show all posts
Showing posts with label gawk. Show all posts
Tuesday, August 16, 2005
Thursday, August 11, 2005
Cygwin, bash, grep, gawk, tclsh, VBScript
What a combination!!
I've found Cygwin enormously helpful. Take the following snippet for example, which extracts the names of all the Subs and Functions from my library file into a file, and then hands that file on to a tcl script.
#!/bin/bash grep -i '^Function ' StdFunctions.vbs >func.lst grep -i '^Sub ' StdFunctions.vbs >> func.lst cat func.lst | gawk -F " " '{ print $2 }' | gawk -F "(" '{ print $1 }' > Routines.lst rm func.lst tclsh routines.tclThe output file, Routines.lst, looks like this (partially)
CreateMDB OpenDatabase OpenDatabase2 SelectSheet GetColumnDownToEnd GetColumnDownToLimit RangeToArray VectorToTwoDimArray RelativeToAbsolute MakeKey3 MakeKey4 TimeStamp Zerofill IsFile IsINISection GetINIStringRoutines.tcl takes this, and an internally specified list of files to check (which I could have coded so as to specify on the commandline) and then tells me whether any of these routines are referred to in the list of files.
#!/bin/tclsh set mm 0 proc searchFile {theFile theString} { #puts "Searching $theFile for $theString" set h [open $theFile r] set d [split [read $h] \n] close $h set c 0 set m 0 foreach dline $d { incr c if {[string match -nocase "*${theString}*" $dline] == 1} then { set m 1 #puts "$theFile $c: $dline" } } return $m } set vlist [list Create.vbs Daily.vbs NewBatchPrepare.vbs convert.vbs] set h [open Routines.lst r] set flist [split [read $h] \n] close $h foreach fitem $flist { if { $fitem == "" } { continue } set mm 0 foreach vfile $vlist { if { $vfile == "" } { continue } #puts "To search for $fitem in $vfile" set r [searchFile $vfile $fitem] if {$r == 0} { #puts "No sign of $fitem in $vfile" } set mm [expr {$mm + $r}] } if { $mm < 1 } { puts "No sign at all of $fitem" } }It's not foolproof. Some routines are used internally by StdFunctions.vbs. But it's helpful.
Subscribe to:
Posts (Atom)