Author Topic: QB64 Enhancements  (Read 5771 times)

0 Members and 1 Guest are viewing this topic.

Offline fatman2021

  • Newbie
  • Posts: 11
    • View Profile
QB64 Enhancements
« on: July 23, 2017, 07:53:37 pm »
BASIC was originally based off of ALGOL 60, FORTRAN II, JOSS. Any enhancements should be more in this direction, IMHO.

ERIC ED029516: Introductory Computer-Based Mechanics; A One Week Sample Course:
https://archive.org/details/ERIC_ED029516

honeywell :: ddp-24 :: DDP-24 FORTRAN II
https://archive.org/details/bitsavers_honeywelld_5501760

A Primer Of Algol 60 Programming
https://archive.org/details/in.ernet.dli.2015.141149
« Last Edit: July 23, 2017, 10:18:21 pm by fatman2021 »

Offline fatman2021

  • Newbie
  • Posts: 11
    • View Profile
Re: QB64 Enhancements
« Reply #1 on: July 23, 2017, 10:38:49 pm »
EXAMPLES:


BASIC:

Code: QB64: [Select]
  1. 100 PRINT "DANPED HARMONIC OSCILLATOR"
  2. 101 PRINT
  3. 110 LET T = 0
  4. 120 LET X = 1
  5. 130 LET V = 0
  6. 132 LET C = .5
  7. 140 LET D = .01
  8. 141 LET P = .1 - D
  9. 142 PRINT "DAMPING CO/1ST. ="; C
  10. 143 PRINT "TIME STEP ="; D
  11. 144 PRINT "INITIAL X ="; X
  12. 145 PRINT "INITIAL V ="; V
  13. 146 PRINT
  14. 147 PRINT " T                   X"
  15. 148 PRINT "------------------------"
  16. 150 LET X = X + V * D
  17. 160 LET V = V - (X + C * V) * D
  18. 170 LET T = T + D
  19. 171 IF T <= P THEN 150
  20. 180 PRINT T; X
  21. 181 LET P = P + .1
  22. 190 IF T < 3 THEN 150
  23. 200 END
  24.  

FORTRAN II
Code: QB64: [Select]
  1.  
  2.    WRITE(6,20)
  3.    WRITE(6,30)
  4.    T=0.
  5.    X=1.
  6.    V=0.
  7.    D=.01
  8.    P=.1-D
  9.    C=.5
  10.    WRITE(6,40)X,V,C
  11.    WRITE(6,50)D,P
  12.    WRITE(6,60)
  13. 10 X=X+V*D
  14.    V=V-(X+C*V)*D
  15.    T=T+D
  16.    IF(T-P)10,10,12
  17. 12 WRITE(6,70)T,X
  18.    P=P+.1
  19.    IF(T-3.)10,10,16
  20. 16 STOP
  21. 20 FORMAT(17H1           DAMPED)
  22. 30 FORMAT(24H      HARMONIC OSCILLATOR,//)
  23. 40 FORMAT(5H    X=,F4.1,4H  V=,F4.1,4H  C=,F5.3)
  24. 50 FORMAT(8H       D=,F5.2,4H  P=,F5.2,//)
  25. 60 FORMAT(22H          T           X)
  26. 70 FORMAT(F10.2,F12.4)
  27.  

JOSS
Code: QB64: [Select]
  1.  
  2. OSCILLATOR: PROCEDURE OPTIONS (MAIN);
  3.             T = 0; X = 1; V = 0; D = .01;
  4.             P = .1 - D;
  5.             C = .5;
  6.             PUT PAGE LIST (' DAMPED OSCILLATOR ');
  7.             PUT SKIP DATA (C, D, X, V);
  8.             PUT SKIP;
  9.             PUT SKIP LIST ('TIME     POSITION');
  10.             PUT SKIP LIST ( (20) '-' );
  11.    CALCULATE:  X = X + V*D; V = V -  (X + C*V )*D; T = T + D;
  12.                IF T<=P THEN GO TO CALCULATE;
  13.                P = P + .1;
  14.                PUT EDIT (T, X) (SKIP, F(5,2), X(5), F(10,6) );
  15.                IF T<3 THEN GO TO CALCULATE;
  16. END OSCILLATOR;
  17.  

Algol 60
Code: QB64: [Select]
  1.  
  2. FIRSTFIVEHUNDREDPRIMES: begin;
  3.     integer J, K, N, Q, R;
  4.     integer array PRIME[1 : 500];
  5.     P1: PRIME[1] := 2;
  6.     N := 3;
  7.     J := 1;
  8.     P2: J := J + 1;
  9.     PRIME[J] := N;
  10.     P3: if J = 500 then goto P9;
  11.     P4: N := N + 2;
  12.     P5: K := 2;
  13.     P6: Q := N mod PRIME[K];
  14.     R := N - Q TIMES PRIME[K];
  15.     if R = 0 then goto P4;
  16.     P7: if Q NOTLESS PRIME[K] then goto P2;
  17.     P8: K := K + 1;
  18.     goto P6;
  19.     P9: OUTSTRING(1, "First Five Hundred Primes\n");
  20.     for J := 1 step 1 until 50 do
  21.       begin;
  22.         for K := 1 step 1 until 10 do
  23.           begin;
  24.             integer P;
  25.             P := PRIME[J + 50 TIMES (K - 1)];
  26.             if P < 1000 then OUTCHAR(1, "0", 1);
  27.             if P < 100 then OUTCHAR(1, "0", 1);
  28.             if P < 10 then OUTCHAR(1, "0", 1);
  29.             OUTINTEGER(1, P);
  30.         end K;
  31.         OUTSTRING(1, "\n");
  32.     end J;
  33. end ;
  34.