mkarrowtbl.sh 942 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #! /bin/ksh
  2. #
  3. # Create an HTML table using the argument images as items.
  4. #
  5. # usage: mkarrowtbl.sh arrow*
  6. #
  7. # where arrow starts with *_ and has a suffix indicating the
  8. # desired output format.
  9. typeset -i I CNT=0
  10. typeset -i LCNT=0
  11. CURRA="xxxx"
  12. function closeLine
  13. {
  14. echo " </TR>"
  15. echo " <TR ALIGN=\"CENTER\">"
  16. for (( I=0;I<CNT;I++ ))
  17. do
  18. echo " <TD>${AS[$I]}</TD>"
  19. done
  20. echo " </TR>"
  21. }
  22. while (( $# > 0 ))
  23. do
  24. ARROW=${1%.*} # abc_arrowname
  25. FMT=${1#$ARROW.} # fmt
  26. A=${ARROW#*_} # arrowname
  27. # Arrows with the same suffix (ignoring .fmt) are put on the same line.
  28. # That is, if the right side of $A is not $CURRA, we start a new line.
  29. if [[ $A != *$CURRA ]]
  30. then
  31. if (( LCNT > 0 ))
  32. then
  33. closeLine
  34. (( CNT=0 ))
  35. fi
  36. echo " <TR ALIGN=\"CENTER\">"
  37. CURRA=$A
  38. (( LCNT++ ))
  39. fi
  40. AS[$CNT]=$A
  41. (( CNT++ ))
  42. echo " <TD><IMG SRC=\"$1\"></TD>"
  43. shift
  44. done
  45. closeLine