0) {
+ n=gsub(/\"/,"",line) # " syntax colouring bad in VS code for awk
+ i += 1
+ jline[i]=line
+ result="working"
+ if (line ~ /survex file/) {
+ result="survexline"
+ n = split(line,arr,":")
+ jsonsvx = trim(arr[n])
+ n=gsub(/,$/,"",jsonsvx) # if it is the last field then no comma
+ urljsonsvx = svxurl jsonsvx
+ #printf("[%s] {%s} ",jsonsvx, urljsonsvx)
+ if (jsonsvx == "") {
+ print "UNSET json ", walldir, $1 > "svx-refs.tmp"
+ printf("sed -i '/survex file/ s;\"\";\"%s\";' %s\n",svxfile, json) > "svx-refs.tmp"
+ printf("%s :: ", wallet)
+ printf("UNSET - json field blank\nsvx :%s:\n",svxfile)
+ result="unset"
+ #break # behaves like next not break
+ } else if (jsonsvx == svxfile ) {
+ printf("%s :: ", urljson,wallet) > "ok.tmp"
+ printf("OK - svx filenames match - %s\n",urljsonsvx,jsonsvx) > "ok.tmp"
+ result="ok"
+ #break # behaves like next not break
+ } else {
+ printf("%s :: ", wallet)
+ printf("MISMATCH %s <-svx %s %s\nMISMATCH %s json-> %s\n",urljson,wallet,urlsvxfile,svxfile,included,urljson,wallet,urljsonsvx,jsonsvx) > "svx-refs.tmp"
+ result="mismatch"
+ #break # behaves like next not break
+ }
+ if (result =="survexline") {
+ printf("%s + FAILTOSET ", wallet)
+ } else {
+ # printf("%s + SET =%s= ", wallet, result)
+ }
+ } else {
+ # This wasn't the right line, read the next one..
+ }
+ } # end of look going through a json file, result should be ok, mismatch or unset
+ if (result=="working") {
+ # as expected if there are lines after the survex line in the json file
+ } else if (result=="survexline") {
+ # the last line in the json was the survex line but failed to set to ok, mismatch or unset
+ printf("%s :: FAILTOSET %s\n", wallet, jsonsvx)
+ #system("cat " json)
+ #for (i in jline ) printf("%s %s\n",i,jline[i])
+ } else {
+ printf("%s :: BIZARRE\n", wallet)
+ #printf("%s :: BIZZARE should not get here\n", wallet) > "svx-refs.tmp"
+ #system("cat " json)
+ #for (i in jline ) printf("%s %s\n",i,jline[i])
+ }
+ } # end of test for missing or empty path or json file
+} # end of test for matching a wallet tag
+END {
+
+}
diff --git a/scripts/old_or_unused/check-refs.sh b/scripts/old_or_unused/check-refs.sh
new file mode 100644
index 000000000..790582f86
--- /dev/null
+++ b/scripts/old_or_unused/check-refs.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Checks that *ref in .svx files link to valid surveyscans folders
+# Assumes that svx-refs has been generated.
+# usage:
+# cd /loser/
+# ./check-refs.sh
+#
+# 2020-04-06 Philip Sargent
+#
+# To make this run in a cron job on the server, we need to do:
+# 1. make the paths correct for the server in chk-refs.sh
+#
+# 2020-04-13
+#
+awk -f check-refs.awk svx-refs
+sort < ok.tmp > svx-refs.ok
+rm ok.tmp
+sort < svx-refs.tmp > svx-refs.err
+rm svx-refs.tmp
+echo "" >../expoweb/svx-refs.err.html
+cat svx-refs.err >>../expoweb/svx-refs.err.html
+echo "
" >>../expoweb/svx-refs.err.html
+echo "" >../expoweb/svx-refs.ok.html
+cat svx-refs.ok >>../expoweb/svx-refs.ok.html
+echo "
" >>../expoweb/svx-refs.ok.html
+
+if test -s svx-refs.err ; then true ; else rm svx-refs.err ; fi
diff --git a/scripts/old_or_unused/check-svx.sh b/scripts/old_or_unused/check-svx.sh
new file mode 100644
index 000000000..72c0e29a1
--- /dev/null
+++ b/scripts/old_or_unused/check-svx.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+echo preparing table of svx *ref links to wallets
+# Checks that *ref in .svx files link to valid surveyscans folders
+# Just prepares the data as a table, does no error checking itself.
+# The validation checking is done by check-refs.sh & check-refs.awk
+# 2020-04-05 Philip Sargent
+#
+# usage:
+# cd /loser/
+# ./check-svx.sh
+#
+# To make this run in a cron job on the server, we need to do:
+# 1. make the paths correct for the server in chk-refs.sh
+# 2020-04-13
+#
+# Many formats used in svx files for *ref statements:
+# ; ref.:
+# ;ref.:
+# ; Ref.:
+# ; Ref.
+# ; Referenz.:
+# ;Referenz.:
+# ; ref:
+# ; ref
+# *Ref
+# *ref
+# *ref
+# *include galatica ; ref
+# *ref 2040#31 ; (additonal comment....)
+#
+find . -name "*.svx" -type f -print0 | xargs -0 -n 1 awk '
+function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s } # remove leading whitespace
+function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s } # remove trailing whitespace
+function trim(s) { return rtrim(ltrim(s)); }
+BEGIN {
+ reftag = "^([ ]*[;]|[*])[ ]?[Rr]ef(erenz)?[.]?[ ]?[:]?"
+ spctag = "[1-2][0-9][0-9][0-9] #X?[0-9][0-9]"
+ walltag = "[1-2][0-9][0-9][0-9]#X?[0-9][0-9]"
+ inctag = "\\*include .*;[ ]*ref"
+ }
+$0 ~ reftag {
+ gsub(reftag,"") # remove the *ref tag
+ $0=trim($0)
+ wallet=match($0,spctag) # matches 2014 #03
+ if (wallet != 0) {
+ $0=substr($0,0,wallet+3) substr($0,wallet+5,length($0)) # makes 2014#03
+ }
+ wallet=match($0,walltag) # matches 2014#X03
+ if (wallet != 0) { # insert a space after the wallet code
+ $0=substr($0,0,wallet+RLENGTH-1) " " substr($0,wallet+RLENGTH,length($0))
+ }
+
+ svxfile=ARGV[1]
+ print substr(svxfile,3,length(svxfile)), $0 # chop off the "./"
+ }
+$0 ~ inctag { #Also references from *include statements:
+ $0=trim($0)
+ svxfile=ARGV[1]
+ svxfile = substr(svxfile,3,length(svxfile)) # chop off the "./"
+ wallet = $5
+ refsvxfile = $2
+ printf("%s %s %s INCLUDE\n",svxfile, wallet, refsvxfile)
+}
+END {
+ }
+' > svx-refs