home *** CD-ROM | disk | FTP | other *** search
/ PC World 1999 October / PCWorld_1999-10_cd1.bin / Hardware / Drivers / ZoomShel / zoom.exe / variable_fun.zsh < prev    next >
Text File  |  1999-02-07  |  2KB  |  51 lines

  1. echo
  2. echo
  3. ##########################################
  4. # Some fun with variables, showing the 
  5. # Zoom Shell implementation of Posix 
  6. # variable syntax, with Zoom Shell extensions
  7. # thrown in as well.
  8. ##########################################
  9. Test=SuperCalaFragalistic Expialadocious
  10. echo Our word for today is:  ${Test}
  11.  
  12. ##########################################
  13. # length 
  14. ##########################################
  15. LenTest=${#Test}
  16. echo The length of our word is:  $LenTest characters.
  17.  
  18. ##########################################
  19. # items in an "array"
  20. ##########################################
  21. ItemCount=${#Test[*]}
  22. echo The number of items in this string is:  $ItemCount
  23. echo The first item is: ${Test[1]}
  24. echo The last item is: ${Test[$ItemCount ]}
  25.  
  26. ##########################################
  27. # substitute in missing variables
  28. ##########################################
  29. echo "test_null" has been set to ${test_null}
  30. echo "test_null" has been set to ${test_null:=nothing at all}
  31. echo "Test" has been set to ${Test:=Empty String}
  32.  
  33. ##########################################
  34. # chop off the left side
  35. ##########################################
  36. Left=Super
  37. echo The part after "${Left}" is:   ${Test#${Left}}
  38.  
  39. ##########################################
  40. # chop off the right side
  41. ##########################################
  42. Right=ious
  43. echo The part before "${Right}" is:  ${Test%${Right}}
  44.  
  45. ##########################################
  46. # substring function
  47. ##########################################
  48. echo Some characters from the middle:  ${Test,8,10}
  49. echo From the twelth character onward:  ${Test,12}
  50. echo This should equal the previous line:  ${Test,12,${LenTest}}
  51.