Author Topic: Dartmouth BASIC  (Read 3614 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
Dartmouth BASIC
« on: June 12, 2018, 09:37:58 AM »
Charles,

I have often referred to you as a saint for delevoping O2 and DLLC. Did you know BASIC was in part developed by a Nun?

Sister Mary Kenneth Keller

Mike Lobanovsky

  • Guest
Re: Dartmouth BASIC
« Reply #1 on: June 12, 2018, 04:30:47 PM »
Dartmouth BASIC was hardly a BASIC in the present-day sense of the word. It was probably for the sake of sister Mary that the letter B appeared in the language name at all.

Just to think of all those old farts that keep on trying to pull us back into the dark ages of the middle of 20th century! ;)

JRS

  • Guest
Re: Dartmouth BASIC
« Reply #2 on: June 12, 2018, 05:48:05 PM »
SB can run Dartmouth BASIC programs untouched except for the DATA statement.

Keep In mind Mike we are talkng 65 years ago.

Business BASIC is a close cousin to Dartmouth BASIC, even today.
« Last Edit: June 12, 2018, 06:30:24 PM by John »

Mike Lobanovsky

  • Guest
Re: Dartmouth BASIC
« Reply #3 on: June 13, 2018, 03:09:07 AM »
In FBSL (and I'm sure in O2 too), the entire Dartmouth standard together with QB-style GDI graphics fits into a moderate 300 to 400 lines large BASIC #include file that you plug into your BASIC project's main file. :)

JRS

  • Guest
Re: Dartmouth BASIC
« Reply #4 on: June 13, 2018, 05:28:22 AM »
I solved the DATA/READ issue with SB SUBs. Variadic arguments ByRef can come in handy. 8)

Attached id the Dartmouth BASIC User Guide.




« Last Edit: June 13, 2018, 09:01:34 AM by John »

JRS

  • Guest
Re: Dartmouth BASIC
« Reply #5 on: June 13, 2018, 02:25:15 PM »
Here is an example out of the Dartmouth BASIC user guide. I added a touch of SB formating to make the output work like DB.

Code: Script BASIC
  1. 10 FOR N = 1 TO 7
  2. 20 PRINT N,"\t",FORMAT("%g",SQR(N)),"\n"
  3. 30 NEXT N
  4. 40 PRINT "DONE\n"
  5. 50 END
  6.  


jrs@jrs-laptop:~/sb/examples/test$ time scriba dmb.sb
1   1
2   1.41421
3   1.73205
4   2
5   2.23607
6   2.44949
7   2.64575
DONE

real   0m0.004s
user   0m0.000s
sys   0m0.000s
jrs@jrs-laptop:~/sb/examples/test$




JRS

  • Guest
Re: Dartmouth BASIC
« Reply #6 on: June 14, 2018, 02:38:26 AM »
This example uses DATA / READ statements which I replaced with SPLIT. I would need to write a C extension module to create a DATA and READ function due to not knowing the number of variadic arguments from the interpreter. The line numbers help identify the substitutions I used.

Code: Script BASIC
  1. 10 SPLIT "1, 2, 4, 2, -7, 5" BY "," TO A, B, D, E, C, F
  2. 15 LET G = A * E - B * D
  3. 20 IF G = 0 THEN GOTO 65
  4. 70 GOSUB 37
  5. 80 SPLIT "1, 3" BY "," TO C, F
  6. 81 GOSUB 37
  7. 82 SPLIT "4, -7" BY "," TO C, F
  8. 83 GOSUB 37
  9. 85 PRINT "OUT OF DATA\n"
  10. 90 END
  11. 37 LET X = ( C * E - B * F ) / G
  12. 42 LET Y = ( A * F - C * D ) / G
  13. 55 PRINT FORMAT("%g", X), "\t", FORMAT("%g", Y), "\n"
  14. 60 RETURN
  15. 65 PRINT "NO UNIQUE SOLUTION\n"
  16.  


jrs@jrs-laptop:~/sb/examples/test$ time scriba linear.sb
4   -5.5
0.666667   0.166667
-3.66667   3.83333
OUT OF DATA

real   0m0.005s
user   0m0.004s
sys   0m0.000s
jrs@jrs-laptop:~/sb/examples/test$



JRS

  • Guest
Re: Dartmouth BASIC
« Reply #7 on: June 14, 2018, 09:40:38 PM »
This example prints the Greatest Common Divisor (GCD) using the Euclidean Algoorithm. It also demonstrates nested GOSUB functionality.

Code: Script BASIC
  1. 10 PRINT " A", "\t\t", " B", "\t\t", " C", "\t\t", "GCD", "\n"
  2. 20 SPLIT "60, 90, 120" BY "," TO A, B, C
  3.    GOSUB 30
  4.    SPLIT "38456, 64872, 98765" BY "," TO A, B, C
  5.    GOSUB 30
  6.    SPLIT "32, 384, 72" BY "," TO A, B, C
  7.    GOSUB 30
  8.    PRINT "OUT OF DATA\n"
  9.    GOTO 320
  10. 30 LET X = A
  11. 40 LET Y = B
  12. 50 GOSUB 200
  13. 60 LET X = G
  14. 70 LET Y = C
  15. 80 GOSUB 200
  16. 90 PRINT A, "\t\t", B, "\t\t", C, "\t\t", G, "\n"
  17. 100 RETURN
  18. 200 LET Q = INT(X / Y)
  19. 210 LET R = X - Q * Y
  20. 220 IF R = 0 THEN GOTO 300
  21. 230 LET X = Y
  22. 240 LET Y = R
  23. 250 GOTO 200
  24. 300 LET G = Y
  25. 310 RETURN
  26. 320 END
  27.  

One thing about Dartmonth and Business BASIC is it's user base use error trapping as a means of flow control. I've always felt it was lazy programming but that's me.
« Last Edit: June 14, 2018, 11:45:06 PM by John »

JRS

  • Guest
Re: Dartmouth BASIC
« Reply #8 on: June 15, 2018, 08:41:47 AM »
This will be my last post on this topic. The point was Script BASIC can be used to run code from the first BASIC developed to VB6 COM/OLE automation and most dialects inbetween.

Mike Lobanovsky

  • Guest
Re: Dartmouth BASIC
« Reply #9 on: June 15, 2018, 10:52:46 AM »
And this is very, very good. This is a feature that distinguishes a modern BASIC from the retro ghosts of the past ages.

JRS

  • Guest
Re: Dartmouth BASIC
« Reply #10 on: June 15, 2018, 02:19:57 PM »
A language that can withstand the test of time earns its salt in my toolbox.

JRS

  • Guest
ECMA-55 Minimal BASIC
« Reply #11 on: June 18, 2018, 09:55:15 PM »
Here is Dartmouth compatible BASIC interpreter for Windows. I''ve also attached a help guide for the BASIC.

sieve.bas
Code: [Select]
5   REM SIEVE OF ERATOSTHENES, BY ERATOSTHENES OF CYERENE, 276 BC - 194 BC
10  PRINT "FIND PRIMES FROM 2 TO N (N <= 1000). ENTER N: "
20  INPUT N
30  IF N<2 THEN 10
40  IF N>1000 THEN 10
50  DIM A(1000)
60  LET S=SQR(N)
70  FOR I=2 TO S
80    IF A(I)=1 THEN 130
90    LET D=N/I
100   FOR J=I TO D
110     LET A(I*J)=1
120   NEXT J
130 NEXT I
140 FOR I=2 TO N
150   IF A(I)=1 THEN 170
160   PRINT I
170 NEXT I
180 END


C:\bas55v116>bas55 sieve.bas
FIND PRIMES FROM 2 TO N (N <= 1000). ENTER N:
? 10
 2
 3
 5
 7

C:\bas55v116>bas55
bas55 1.16

This is free software: you are free to change and redistribute it,
but there is NO WARRANTY. Type LICENSE to show the details.

Type HELP for a list of allowed commands.
Ready.
load "sieve.bas"
sieve.bas
Ready.
list
5   REM SIEVE OF ERATOSTHENES, BY ERATOSTHENES OF CYERENE, 276 BC - 194 BC
10  PRINT "FIND PRIMES FROM 2 TO N (N <= 1000). ENTER N: "
20  INPUT N
30  IF N<2 THEN 10
40  IF N>1000 THEN 10
50  DIM A(1000)
60  LET S=SQR(N)
70  FOR I=2 TO S
80    IF A(I)=1 THEN 130
90    LET D=N/I
100   FOR J=I TO D
110     LET A(I*J)=1
120   NEXT J
130 NEXT I
140 FOR I=2 TO N
150   IF A(I)=1 THEN 170
160   PRINT I
170 NEXT I
180 END
Ready.


Here is the Script BASIC version.
Code: Script BASIC
  1. ' SIEVE OF ERATOSTHENES, BY ERATOSTHENES OF CYERENE, 276 BC - 194 BC
  2. 10  PRINT "FIND PRIMES FROM 2 TO N (N <= 1000). ENTER N: "
  3. 20  LINE INPUT N
  4.     N = VAL(CHOMP(N))
  5. 30  IF N<2 THEN GOTO 10
  6. 40  IF N>1000 THEN GOTO 10
  7.  
  8. 60  LET S=SQR(N)
  9. 70  FOR I=2 TO S
  10. 80    IF A[I]=1 THEN GOTO 130
  11. 90    LET D=N/I
  12. 100   FOR J=I TO D
  13. 110     LET A[I*J]=1
  14. 120   NEXT J
  15. 130 NEXT I
  16. 140 FOR I=2 TO N
  17. 150   IF A[I]=1 THEN GOTO 170
  18. 160   PRINT I,"\n"
  19. 170 NEXT I
  20. 180 END
  21.  


C:\bas55v116>scriba sieve.sb
FIND PRIMES FROM 2 TO N (N <= 1000). ENTER N: 10
2
3
5
7

C:\bas55v116>


The FNx inline functions are like a macro. No FUNCTION / SUB in Minimal. You do have GOSUB / RETURN for code blocks.

The other limitation in ECMA-55 is there is no sub-string access functions. In Business BASIC a sub-string is represented as A$(start[,length]) without having to do a MID$() function.

No file access other than LOAD / SAVE.

« Last Edit: June 19, 2018, 12:20:02 AM by John »