home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1992 / 13 / mul.bat < prev    next >
DOS Batch File  |  1991-11-22  |  2KB  |  67 lines

  1. echo off
  2. cls
  3. if %1!==! goto instr
  4. echo Calculations are in PROGRESS!
  5. :calc
  6. strings /p~ decpos1 = find ~~%1~.
  7. if not %decpos1%==0 goto havedec1
  8. set num1=%1
  9. goto two
  10. :havedec1
  11. strings decpos1 = sub %decpos1%,1
  12. strings num1 = left %1,%decpos1%
  13. strings decpos1 = add %decpos1%,2
  14. strings dec1 = mid %1,%decpos1%,128
  15. strings decpl1 = length %dec1%
  16. set num1=%num1%%dec1%
  17. :two
  18. strings /p~ decpos2 = find ~~%2~.
  19. if not %decpos2%==0 goto havedec2
  20. set num2=%2
  21. goto doprod
  22. :havedec2
  23. strings decpos2 = sub %decpos2%,1
  24. strings num2 = left %2,%decpos2%
  25. strings decpos2 = add %decpos2%,2
  26. strings dec2 = mid %2,%decpos2%,128
  27. strings decpl2 = length %dec2%
  28. set num2=%num2%%dec2%
  29. :doprod
  30. strings prod = mul %num1%,%num2%
  31. strings #decpl = add %decpl1%,%decpl2%
  32. strings decprt = right %prod%,%#decpl%
  33. strings prodlen = length %prod%
  34. strings intgrlen = sub %prodlen%,%#decpl%
  35. strings intgrprt = left %prod%,%intgrlen%
  36. set answer=%intgrprt%.%decprt%
  37. echo %1 X %2 = %answer%
  38. set decpos1=
  39. set dec1=
  40. set decpl1=
  41. set num1=
  42. set decpos2=
  43. set dec2=
  44. set decpl2=
  45. set num2=
  46. set prod=
  47. set #decpl=
  48. set decprt=
  49. set prodlen=
  50. set intgrlen=
  51. set intgrprt=
  52. set answer=
  53. goto end
  54. :instr
  55. echo X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
  56. echo.
  57. echo             Enter the numbers you wish multiplied after %0.
  58. echo.
  59. echo                           such as:   MUL 125.75 5.65
  60. echo.
  61. echo    The product will display as many decimal places as were entered.
  62. echo.
  63. echo  X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
  64. :end
  65. echo.
  66. echo.
  67.