home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / shell / 3625 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  1.8 KB

  1. Path: sparky!uunet!sun-barr!ames!agate!bionet!uwm.edu!rpi!newsserver.pixel.kodak.com!laidbak!tellab5!vpnet!serveme!gagme!dattier
  2. From: dattier@gagme.chi.il.us (David W. Tamkin)
  3. Newsgroups: comp.unix.shell
  4. Subject: Re: Calling a function from a case loop.
  5. Message-ID: <1992Aug25.035527.25059@gagme.chi.il.us>
  6. Date: 25 Aug 92 03:55:27 GMT
  7. References: <4785@daily-planet.concordia.ca>
  8. Sender: usenet@serveme.chi.il.us
  9. Distribution: comp.unix.shell
  10. Organization: Gagme Public Access Seraglio, Chicago, Illinois  60656-1252
  11. Lines: 41
  12. Originator: dattier@gagme
  13.  
  14. gsa@alcor.concordia.ca (a surnameless "Dan") wrote in
  15. <4785@daily-planet.concordia.ca>:
  16.  
  17. | Has anyhone tried calling a function from a case condition?
  18. | This one doesn't seem to work:
  19. |  
  20. | read selection
  21. | case $selection in
  22. |  
  23. | 1)
  24. | call_some_funtion() ;;
  25.                    ^^
  26. |  
  27. | esac
  28. | done
  29. | exit 0
  30. |                       
  31. | call_some_funtion()
  32. | {
  33. | echo "Hello World"
  34. | }
  35.  
  36. First, be sure that a seventeen-letter identifier like "call_some_funtion"
  37. is a legal function name for your shell and your OS.  You didn't tell us
  38. which those are.
  39.  
  40. Second, if you're using sh, ksh, or bash, "()" should be only in the
  41. definition of the function and not in a call to it.
  42.  
  43. Third, you named the function "call_some_funtion" with no c before the t.
  44. You spelled it the same way both places in your post, but did you spell it
  45. the same way both times when you tried it?
  46.  
  47. Fourth, when the script is scanned (at least sh and ksh can work this way)
  48. the function was called at a place where it wasn't yet defined.  Try putting
  49. the function definition at the beginning of the script.
  50.  
  51. Good luck.  I know it can work; I've done it.
  52.  
  53. David W. Tamkin   Box 59297   Northtown Station, Illinois  60659-0297
  54. dattier@gagme.chi.il.us   CompuServe: 73720,1570   MCI Mail: 426-1818
  55.