home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1946 / sp2xgraph < prev   
Encoding:
Text File  |  1990-12-28  |  2.0 KB  |  78 lines

  1. #!/bin/csh 
  2. set ylabel="Voltage"
  3. set xlabel="Time"
  4. while ($#argv > 0) 
  5.     switch ("$argv[1]")
  6.     case -i:
  7.         if ($#argv <1) goto usageerror
  8.         set ylabel="Current"
  9.         shift
  10.         breaksw
  11.     case -f:
  12.         if ($#argv < 1) goto usageerror
  13.         set xlabel="Frequency"
  14.         shift
  15.         breaksw
  16.     case -xl:
  17.         if ($#argv < 2) goto usageerror
  18.         set xlabel="$argv[2]"
  19.         shift
  20.         shift
  21.         breaksw
  22.     case -yl:
  23.         if ($#argv < 2) goto usageerror
  24.         set ylabel="$argv[2]"
  25.         shift
  26.         shift
  27.         breaksw
  28.     case -pn:
  29.         if ($#argv < 2) goto usageerror
  30.         set plotname="$argv[2]"
  31.         shift
  32.         shift
  33.         breaksw
  34.     case -s:
  35.         set fn    
  36.         if !($?plotname) set plotname=$fn endif
  37.         shift
  38.         breaksw
  39.     default:
  40.         set fn=$argv[1]
  41.         if !($?plotname) set plotname=$fn endif
  42.         shift
  43.         breaksw
  44.     endsw
  45. end
  46.  
  47. if ($?fn) then
  48. sed -e '/\ $/,/^----/d' -e 's/^Index  *[^ ]*  */\"/' -e 's/^  *.*$//' -e '/^--*/d' -e 's/^0 */move /' -e 's/^[0-9]*//' -e '1i\\
  49. TitleText: '"$plotname"'\\
  50. XUnitText: '"$xlabel"'\\
  51. YUnitText: '"$ylabel"' ' -e 's/\,[     ]*[+-0-9e]*//g' $fn
  52. else
  53. usage:
  54. echo -n
  55. echo 'Usage:'" $0 [options] filename"
  56. echo "This program translates spice3 print command output to xgraph input format."
  57. echo "It WILL handle multiple variables in one file- provided they were put there"
  58. echo "by _consecutive_ print statements. ie. 'print i1 i2 > filename' will not work"
  59. echo "but 'print i1 > filename' followed by 'print i2 >> filename' WILL work."
  60. echo "Output is on stdout. Author: jmn@power.berkeley.edu"
  61. echo "Options are:"
  62. echo "  -i        Set YAxisLabel to 'Current' (default is 'Voltage')"
  63. echo "  -f         Set XaxisLabel to 'Frequency' (default is 'Time')"
  64. echo "  -xl XName    Set XaxisLabel to Xname"
  65. echo "  -yl YName    Set YaxisLabel to Yname"
  66. echo "  -pn PlotName    Set PlotTitle to PlotName (default is filename)"
  67. echo "  -s        Take input from stdin"
  68. echo -n
  69. echo "Example Usage:"
  70. echo "$0 -xl 'log(frequency)' -yl 'Gain(db)' -pn '741 Plot' filename | xgraph"
  71. echo "will plot a graph called '741 Plot' with Gain(db) vs log(frequency)."
  72. exit 1
  73. usageerror:
  74.     echo $argv[1] needs more arguments!
  75.     goto usage
  76.  
  77. endif
  78.