home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 01e / let12.zip / DEMO-10.BAT < prev    next >
DOS Batch File  |  1987-09-17  |  2KB  |  62 lines

  1. echo Off
  2. If `%Name%' == `' Demo
  3. cls
  4. echo   ╔════════════════════════════════════════════════════════════════╗
  5. echo ┌─╫────────────────────────────────────────────────────────────────╫─┐
  6. echo │ ║   Data Formatting: FILL                                        ║ │
  7. echo └─╫────────────────────────────────────────────────────────────────╫─┘
  8. echo   ╚════════════════════════════════════════════════════════════════╝
  9. echo  
  10. echo Here's a handy little feature: data formatting.
  11. echo  
  12. echo This is how we do it.  Imagine a template, or pattern as we'll
  13. echo call it, which consist of two kinds of characters: fill-characters
  14. echo and "stuff."  For example, we have a pattern below:
  15. set Rfill=≤≤≤,≤≤≤,≤≤≤,≤≤≤.≤≤
  16. echo  
  17. echo         %Rfill%
  18. echo  
  19. echo The little less-than-or-equal signs (≤) are fill-characters, and the
  20. echo commas and period are "stuff."  Imagine now, that we can fill data
  21. echo into this pattern, in effect replacing the fill-characters with data,
  22. echo but leaving the "stuff."  Here: I'll show you.  What is your self-
  23. echo estimated value to your employer (this is usually your salary with the
  24. echo decimal point moved a few places to the right)  Try to keep it a number
  25. echo less than a million--understatement is the better part of tact.
  26. LET num=(replace (ask "Well? What are you worth? ") "$" "" "," "" " " "")
  27. LET P=(pos num ".")
  28. if     %P% == 0 LET num=(concat num "00")
  29. if not %P% == 0 LET num=(replace num "." "")
  30. echo I've doctored that number up so that I can use it: %num%
  31. echo Now, let us fill that number into your pattern and see what we get.
  32. LET result=(fill Rfill (concat "            " num))
  33. echo  
  34. echo This gives us the result of "%result%"
  35. echo But wait!  We can suppress the "stuff" that shouldn't be there!
  36. echo (I deliberately prevented the suppression to show you how data
  37. echo gets filled.)  Any leading commas can be zapped away--
  38. LET dummy=(ask "automatically--press RETURN to go on. ")
  39. LET result=(fill Rfill num " ")
  40. echo  
  41. echo With suppression, we get
  42. echo  
  43. echo "%result%"
  44. echo  
  45. echo You want a floating dollarsign? Ok.
  46. LET result=(fill Rfill num " $")
  47. echo  
  48. echo "%result%"
  49. echo  
  50. echo How about asterisk filling
  51. LET result=(fill Rfill num "*$")
  52. echo  
  53. echo "%result%"
  54. echo  
  55. Echo How's that?
  56. set Result=
  57. set Rfill=
  58. set P=
  59. set num=
  60. pause
  61. DEMO-11
  62.