diff --git a/sim/GetLineNum.do b/sim/GetLineNum.do new file mode 100644 index 00000000..4d38d912 --- /dev/null +++ b/sim/GetLineNum.do @@ -0,0 +1,18 @@ +# Alec Vercruysse +# 2023-04-12 +# Note that the target string is regex, and needs to be double-escaped. +# e.g. to match a (, you need \\(. +proc GetLineNum {fname target} { + set f [open $fname] + set linectr 1 + while {[gets $f line] != -1} { + if {[regexp $target $line]} { + close $f + return $linectr + } + incr linectr + } + close $f + return -code error \ + "target string not found" +}