#!/bin/sh # # Input form for "qtcindex.tab" # cls() { echo  return } clear_all_fields() { ar="" nr="" titel_1=""; sid_1=""; titel_2=""; sid_2=""; titel_3=""; sid_3="" titel_4=""; sid_4=""; titel_5=""; sid_5=""; titel_6=""; sid_6="" titel_7=""; sid_7=""; titel_8=""; sid_8=""; titel_9=""; sid_9="" titel_10=""; sid_10=""; titel_11=""; sid_11=""; titel_12=""; sid_12="" titel_13=""; sid_13=""; titel_14=""; sid_14=""; titel_15=""; sid_15="" titel_16=""; sid_16=""; titel_17=""; sid_17=""; titel_18=""; sid_18="" titel_19=""; sid_19=""; titel_20=""; sid_20=""; titel_21=""; sid_21="" titel_22=""; sid_22=""; titel_23=""; sid_23=""; titel_24=""; sid_24="" titel_25=""; sid_25=""; titel_26=""; sid_26=""; titel_27=""; sid_27="" titel_28=""; sid_28=""; titel_29=""; sid_29=""; titel_30=""; sid_30="" titel_31=""; sid_31=""; titel_32=""; sid_32=""; titel_33=""; sid_33="" titel_34=""; sid_34=""; titel_35=""; sid_35=""; titel_36=""; sid_36="" titel_37=""; sid_37=""; titel_38=""; sid_38=""; titel_39=""; sid_39="" titel_40=""; sid_40="" spec_1=""; spec_2=""; spec_3=""; spec_4=""; spec_5=""; spec_6="" spec_7=""; spec_8=""; spec_9=""; spec_10="" return } draw_screen() { cls case $display_page in 1) echo " År: $ar Nr: $nr 01: $titel_1 $sid_1 02: $titel_2 $sid_2 03: $titel_3 $sid_3 04: $titel_4 $sid_4 05: $titel_5 $sid_5 06: $titel_6 $sid_6 07: $titel_7 $sid_7 08: $titel_8 $sid_8 09: $titel_9 $sid_9 10: $titel_10 $sid_10 11: $titel_11 $sid_11 12: $titel_12 $sid_12 13: $titel_13 $sid_13 14: $titel_14 $sid_14 15: $titel_15 $sid_15 " ;; 2) echo " 16: $titel_16 $sid_16 17: $titel_17 $sid_17 18: $titel_18 $sid_18 19: $titel_19 $sid_19 20: $titel_20 $sid_20 21: $titel_21 $sid_21 22: $titel_22 $sid_22 23: $titel_23 $sid_23 24: $titel_24 $sid_24 25: $titel_25 $sid_25 26: $titel_26 $sid_26 27: $titel_27 $sid_27 28: $titel_28 $sid_28 29: $titel_29 $sid_29 30: $titel_30 $sid_30 " ;; 3) echo " 31: $titel_31 $sid_31 32: $titel_32 $sid_32 33: $titel_33 $sid_33 34: $titel_34 $sid_34 35: $titel_35 $sid_35 36: $titel_36 $sid_36 37: $titel_37 $sid_37 38: $titel_38 $sid_38 39: $titel_39 $sid_39 40: $titel_40 $sid_40 " ;; 4) echo " x1: $spec_1 x2: $spec_2 x3: $spec_3 x4: $spec_4 x5: $spec_5 x6: $spec_6 x7: $spec_7 x8: $spec_8 x9: $spec_9 x10: $spec_10 " ;; esac echo -n "Command (å, n, 1-40, x1-x10, +, -, a, c, q, ?): " return } help() { cls echo " å edit year n edit no 1-40 edit title x1-x10 edit special + next page - previous page a add record c clear all fields q query ? this help page " read } chk_first() { if [ $first -eq 0 ]; then awk_string="$awk_string && " fi first=0 return } query() { first=1 awk_string="BEGIN {FS = \" \"}; " if [ "$titel_1" = "" ]; then if [ "$ar" != "" ]; then chk_first awk_string="$awk_string (\$1 ~ /$ar/)" fi if [ "$nr" != "" ]; then chk_first awk_string="$awk_string (\$2 ~ /$nr/)" fi else awk_string="$awk_string (\$3\"\t\"\$5\"\t\"\$7\"\t\"\ \$9\"\t\"\$11\"\t\"\$13\"\t\"\$15\"\t\"\$17\"\t\"\$19\"\t\"\$21\"\t\"\ \$23\"\t\"\$25\"\t\"\$27\"\t\"\$29\"\t\"\$31\"\t\"\$33\"\t\"\$35\"\t\"\ \$37\"\t\"\$39\"\t\"\$41\"\t\"\$43\"\t\"\$45\"\t\"\$47\"\t\"\$49\"\t\"\ \$51\"\t\"\$53\"\t\"\$55\"\t\"\$57\"\t\"\$59\"\t\"\$61\"\t\"\$63\"\t\"\ \$65\"\t\"\$67\"\t\"\$69\"\t\"\$71\"\t\"\$73\"\t\"\$75\"\t\"\$77\"\t\"\ \$79\"\t\"\$81\"\t\"\$82\"\t\"\$83\"\t\"\$84\"\t\"\$85\"\t\"\$86\"\t\"\ \$87\"\t\"\$88\"\t\"\$89\"\t\"\$90\"\t\"\$91\"\t\"\$92 ~ /$titel_1/)" fi awk_string="$awk_string { printf \"Ar: %s\nNr: %s\n\n\ %-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n\ %-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n\ %-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n\ %-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n%-75s%s\n\ %s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n\",\ \$1, \$2, \$3, \$4, \$5, \$6, \$7, \$8, \$9, \$10, \$11, \$12, \$13, \ \$14, \$15, \$16, \$17, \$18, \$19, \$20, \$21, \$22, \$23, \$24, \ \$25, \$26, \$27, \$28, \$29, \$30, \$31, \$32, \$33, \$34, \$35, \ \$36, \$37, \$38, \$39, \$40, \$41, \$42, \$43, \$44, \$45, \$46, \ \$47, \$48, \$49, \$50, \$51, \$52, \$53, \$54, \$55, \$56, \$57, \ \$58, \$59, \$60, \$61, \$62, \$63, \$64, \$65, \$66, \$67, \$68, \ \$69, \$70, \$71, \$72, \$73, \$74, \$75, \$76, \$77, \$78, \$79, \ \$80, \$81, \$82, \$83, \$84, \$85, \$86, \$87, \$88, \$89, \$90, \ \$91, \$92 }" cls awk "$awk_string" $datafile | less return } ######################################################################### ######################################################################### display_page=1 datafile=~/datafiles/qtcindex.tab draw_screen while read r; do case $r in å) echo -n "År: " read ar ;; n) echo -n "Nr: " read nr ;; [1-9] | [1-4][0-9]) if [ $r -gt 40 ]; then echo "Invalid number" sleep 1 else echo -n "Titel $r: " read titel_$r echo -n "Sid $r: " read sid_$r fi ;; x[1-9] | x10) n=${r#"x"} echo -n "Spec $n: " read spec_$n ;; +) if [ $display_page -ne 4 ]; then display_page=$[$display_page + 1] fi ;; -) if [ $display_page -ne 1 ]; then display_page=$[$display_page - 1] fi ;; a) echo "$ar $nr $titel_1 $sid_1 \ $titel_2 $sid_2 $titel_3 $sid_3 $titel_4 $sid_4 \ $titel_5 $sid_5 $titel_6 $sid_6 $titel_7 $sid_7 \ $titel_8 $sid_8 $titel_9 $sid_9 $titel_10 $sid_10 \ $titel_11 $sid_11 $titel_12 $sid_12 $titel_13 $sid_13 \ $titel_14 $sid_14 $titel_15 $sid_15 $titel_16 $sid_16 \ $titel_17 $sid_17 $titel_18 $sid_18 $titel_19 $sid_19 \ $titel_20 $sid_20 $titel_21 $sid_21 $titel_22 $sid_22 \ $titel_23 $sid_23 $titel_24 $sid_24 $titel_25 $sid_25 \ $titel_26 $sid_26 $titel_27 $sid_27 $titel_28 $sid_28 \ $titel_29 $sid_29 $titel_30 $sid_30 $titel_31 $sid_31 \ $titel_32 $sid_32 $titel_33 $sid_33 $titel_34 $sid_34 \ $titel_35 $sid_35 $titel_36 $sid_36 $titel_37 $sid_37 \ $titel_38 $sid_38 $titel_39 $sid_39 $titel_40 $sid_40 \ $spec_1 $spec_2 $spec_3 $spec_4 $spec_5 $spec_6 $spec_7 $spec_08 \ $spec_9 $spec_10" >> $datafile clear_all_fields ;; c) clear_all_fields ;; q) query ;; \?) help ;; esac draw_screen done cls .