home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug003.arc / PASCAL.003 < prev    next >
Text File  |  1979-12-31  |  6KB  |  148 lines

  1.                        PASCAL_FOR_BASIC_PROGRAMMERS.
  2.  
  3.                                Dixoε Kenney.
  4.  
  5.                                  PAR╘ III.
  6.  
  7.      Iεá thi≤á par⌠á oµ thσ series¼á wσ wil∞ looδ a⌠á assigninτá value≤á t∩ ì
  8. variable≤ withiε thσ program¼á anΣ thσ I╞ .«á THE╬ construct«  Looδ a⌠ thi≤ ì
  9. listinτ - 
  10.  
  11. Ö 1Ö Prograφ Banking_2a;
  12.  
  13. Ö 3Ö √ *¬ Versioε 2ß oµ thσ Bankinτ prograφ accept≤ onσ transaction
  14. Ö 4Ö  *¬ froφ thσ keyboard¼ calculate≤ ß ne≈ balance¼ anΣ print≤ out
  15. Ö 5Ö  *¬ thσ relevan⌠ informatioε oε thσ screen}
  16.  
  17. Ö 7Ö √ *¬ Declaratioε Par⌠ }
  18.  
  19. Ö 9Ö Var
  20.  
  21. 11Ö   CustNamσ  ║ String[20];
  22. 12Ö   AccNuφ    ║ Integer;
  23. 13Ö   OpBalance¼ Transaction¼ CBalancσ ║ Real;
  24.  
  25. 15Ö √ *¬ Prograφ Bod∙ }
  26.  
  27. 17Ö Begin
  28.  
  29. 19Ö   ClrScr;
  30. 20Ö   Writeln╗  Writeln;
  31. 21Ö   Write('Custome≥ Namσ  ║ ');
  32. 22Ö   Readln(CustName);
  33. 23Ö   Write('Accoun⌠ Numbe≥ ║ ');
  34. 24Ö   Readln(AccNum);
  35. 25Ö   Write('Openinτ Balance║ ');
  36. 26Ö   Readln(OpBalance);
  37. 27Ö   Write('Amoun⌠ oµ Transaction║ ');
  38. 28Ö   Readln(Transaction);
  39.  
  40. 30Ö √ *¬ Calculatσ thσ ne≈ balancσ }
  41. 32Ö   CBalancσ :╜ OpBalancσ ½ Transaction;
  42.  
  43. 34Ö √ *¬ Writσ ou⌠ thσ ne≈ informatioε oε thσ screeε }
  44.  
  45. 36Ö   ClrScr;
  46. 37Ö   Write('Accoun⌠ Number':20);
  47. 38Ö   Write('Custome≥ Name':20);
  48. 39Ö   Writeln╗ Writeln;
  49. 40Ö   Write(AccNum:20);
  50. 41Ö   Write(CustName:20);
  51. 42Ö   Writeln╗  Writeln;
  52. 43Ö   Write('Openinτ Balancσ     ║ ');
  53. 44Ö   Writeln(OpBalance:10:2);
  54. 45Ö   Write('Transactioε Amoun⌠ ║ ');
  55. 46Ö   Writeln(Transaction:10:2);
  56. 47Ö   Write('Closinτ Balancσ     ║ ');
  57. 48Ö   Writeln(CBalance:10:2)
  58.  
  59. 50Ö ô End.ô    √ *¬ Prograφ Bankinτ 2ß }è     Iε linσ 13¼á wσ havσ addeΣ tw∩ morσ variablσ name≤ t∩ thσ lis⌠ oµ rea∞ ì
  60. number≤á whicΦ occu≥ iε thσ program«á  Notσ ho≈ wσ havσ pu⌠ theφ al∞ oε onσ ì
  61. line«á  The∙á caεá bσá entereΣ eithe≥ separately¼á o≥á oεá thσá samσá line¼ ì
  62. dependinτ oε you≥ programminτ style.
  63.  
  64.      Iεá linσ 32¼á wσ havσ ou≥ firs⌠ assignmen⌠ statement«á  Wσ havσ haΣ t∩ ì
  65. declarσá thσá existencσ oµ thσ variable≤ t∩ thσ prograφ beforσ wσá caεá usσ ì
  66. theφ - thi≤ wa≤ donσ iε linσ 13«á  Noticσ thσ assignmen⌠ sign«  I⌠ i≤ NO╘ █ ì
  67. ╜á ▌á a≤ iε BASIC¼á bu⌠ █ :╜ ]«á  ╔ havσ founΣ tha⌠ onσá oµá BASIC'≤á grea⌠ ì
  68. weaknesse≤á i≤á thσá usσ oµ thσ █ ╜ ▌ fo≥ tw∩á distinc⌠á meanings«á  Pasca∞ ì
  69. clear≤ thi≤ up.
  70.  
  71.      ╜   ha≤ thσ meaninτ "i≤ equa∞ t∩ (logically)
  72.      :╜  ha≤ thσ meaninτ "i≤ assigneΣ thσ valuσ of"
  73.  
  74.           Iε BASIC¼ thσ equivalen⌠ statemen⌠ i≤ LET.
  75.  
  76. Usσ thσ █ :╜ ▌ assignmen⌠ symbo∞ whereve≥ yo⌡ woulΣ usσ LE╘ iε BASIC.
  77.  
  78.      No≈á let'≤ var∙ thσ prograφ b∙ havinτ i⌠ prin⌠ ou⌠ ß nast∙ messagσá iµ ì
  79. thσá custome≥á trie≤á t∩ overdra≈ hi≤ account¼á anΣá no⌠á allowinτá sucΦá ß ì
  80. withdrawa∞ t∩ takσ place«  Thσ firs⌠ 2╕ line≤ oµ thi≤ pro-graφ arσ thσ samσ ì
  81. a≤ 2a¼ s∩ I'l∞ omi⌠ theφ t∩ savσ space.
  82.  
  83. Ö ▒ Ö  Prograφ Banking_2b;
  84.  
  85. 30Ö √ *¬ Tes⌠ t∩ seσ iµ thσ custome≥ ha≤ enougΦ money;
  86. 31Ö  *¬ iµ so¼ calculatσ thσ ne≈ balancσ }
  87.  
  88. 33Ö   Iµ OpBalancσ ½ Transactioε ╝ 0.░ then
  89. 34Ö      Beginô                  √ prin⌠ ß nast∙ messagσ }
  90. 35Ö         ClrScr;
  91. 36Ö         Writeln╗ Writeln;
  92. 37Ö         Writeln('Insufficien⌠ Fund≤ - d∩ no⌠ 
  93.                               allo≈ Withdrawal');
  94. 38Ö         Delay(3000);
  95. 39Ö         ClrScr
  96. 40Ö      Endô                   √ iµ CBalancσ ╝ ░ }
  97. 41Ö   Else
  98. 42Ö      Begin
  99. 43Ö         CBalancσ :╜ OpBalancσ ½ Transaction;
  100. 44Ö         ClrScr;
  101. 45Ö         Write('Accoun⌠ Number':20);
  102. 46Ö         Write('Custome≥ Name':20);
  103. 47Ö         Writeln╗ Writeln;
  104. 48Ö         Write(AccNum:20);
  105. 49Ö         Write(CustName:20);
  106. 50Ö         Writeln╗  Writeln;
  107. 51Ö         Write('Openinτ Balancσ     ║ ');
  108. 52Ö         Writeln(OpBalance:10:2);
  109. 53Ö         Write('Transactioε Amoun⌠ ║ ');
  110. 54Ö         Writeln(Transaction:10:2);
  111. 55Ö         Write('Closinτ Balancσ     ║ ');
  112. 56Ö         Writeln(CBalance:10:2)
  113. 57Ö      Endô                    √ elsσ allo≈ thσ transactioε }
  114.  
  115. 59Ö End.ô    √ *¬ Prograφ Bankinτ 2ß }
  116.  
  117. è     Iεá linσá 3│á oµá versioε 2Γ wσ havσ aεá I╞á .«á THE╬á construct«á  I⌠ ì
  118. function≤á iε exactl∙ thσ samσ wa≤ a≤ BASI├ does¼á eveε t∩ havinτá aεá ELS┼ ì
  119. statemen⌠ ¿ linσ 4▒ )«á  However¼á ß compounΣ blocδ oµ statement≤ iε eithe≥ ì
  120. thσá THE╬á blocδ ¿ o≥ thσ ELS┼ blocδ iµ i⌠ exist≤ ⌐ i≤ markeΣ iε thσá usua∞ ì
  121. Pasca∞á wa≤ witΦ thσ reserveΣ word≤ BEGI╬ anΣ EN─ ¿ noticσ line≤ 34/4░á anΣ ì
  122. 42/5╖ )«á  Noticσ tha⌠ therσ i≤ n∩ semi-coloε afte≥ thσ THEN¼ no≥ beforσ o≥ ì
  123. afte≥ thσ ELS┼ statement«á  Word≤ sucΦ a≤ these¼ anΣ END¼ arσ considereΣ t∩ ì
  124. bσ statemen⌠ separator≤ iε thei≥ owε right¼ anΣ don'⌠ neeΣ thσ █ ╗ ▌ signa∞ ì
  125. arounΣ them.
  126.  
  127.      Iε linσ 3╕ therσ i≤ ß timinτ loop«  Thi≤ function¼ likσ other≤ wσ havσ ì
  128. used¼á i≤ peculia≥ t∩ Turb∩ Pascal«á  Thσ dela∙ i≤ timeΣ iε millisecond≤á - ì
  129. herσá wσ arσ delayinτ executioε oµ thσ prograφ fo≥ 300░ milliseconds¼á o≥ │ ì
  130. seconds«  
  131.  
  132.  
  133.      Iε BE┼ BASIC¼ thσ equivalen⌠ oµ thi≤ statemen⌠ i≤ PLA┘ 0,24.Ö     
  134.  
  135.  
  136.      Remembe≥ tha⌠ iε thσ prograφ listing≤ iε thi≤ series¼ thσ linσ number≤ ì
  137. arσá addeΣ fo≥ conveniencσ oµ reference¼á anΣ arσ NO╘ par⌠ oµ thσá program«  ì
  138. Pasca∞á doe≤á no⌠ usσ linσ numbers«á  Thσ word≤á under-lineΣá arσá reserveΣ ì
  139. words¼á whicΦá canno⌠ bσ re-defined«á  The∙ arσ no⌠ underlineΣ wheε yo⌡ arσ ì
  140. writinτ you≥ program╗ therσ arσ underlineΣ herσ simpl∙ t∩ dra≈ attentioε t∩ ì
  141. them.
  142.  
  143.                             END OF PART THREE.
  144.  
  145.  
  146.  
  147.  
  148.