home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / ebut10.zip / ebuttons-1.0 / make_ebuttons < prev    next >
Text File  |  1992-11-28  |  763b  |  39 lines

  1. #!/bin/sh
  2.  
  3. buttons=ebuttons.h
  4.  
  5. case $# in
  6.     1) ;;
  7.     *) echo usage: `basename $0` num_buttons; exit 1;;
  8. esac
  9.  
  10. if [ -f $buttons ]
  11. then
  12.     existing_buttons="`grep COMMAND $buttons | wc -l`"
  13.     
  14.     if [ $1 -eq `expr $existing_buttons - 2` ]
  15.     then
  16.         exit 0
  17.     fi
  18. fi
  19.  
  20. cat >$buttons <<EOT
  21. #define LABEL(x)   "Label", XtRString, sizeof(String), XtOffsetOf(AppResources, labels[(x)]), XtRString, NULL
  22. #define COMMAND(x) "Command", XtRString, sizeof(String), XtOffsetOf(AppResources, commands[(x)]), XtRString, NULL
  23.  
  24. static XtResource resources[] = {
  25. EOT
  26.  
  27. awk <&- >> $buttons 'BEGIN { \
  28.      for (; i < '$1'; i++) \
  29.        printf "    { \"label%d\", LABEL(%d) },\n    { \"command%d\", COMMAND(%d) },\n", i, i, i, i}'
  30.  
  31. cat >>$buttons <<EOT
  32. };
  33.  
  34. #undef LABEL
  35. #undef COMMAND
  36. EOT
  37.  
  38. exit 0
  39.