Author Topic: QB(64) vs. (Open)COMAL?  (Read 3815 times)

0 Members and 1 Guest are viewing this topic.

Offline freetrav

  • Newbie
  • Posts: 45
    • View Profile
QB(64) vs. (Open)COMAL?
« on: December 28, 2018, 03:40:28 pm »
Although it seems to be more-or-less stable and dead, COMAL also seems to have been an attempt at addressing the same issues with BASIC that led to QB in preference to GW. There is currently a stable working implementation linked from http://www.josvisser.nl/opencomal/. Has anyone ever taken a serious look at COMAL and compared it to QB? Would anyone care to opine?

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Re: QB(64) vs. (Open)COMAL?
« Reply #1 on: December 28, 2018, 05:34:06 pm »
O my did not know that existed - mix of pascal and qb - my two fav languages.. gonna take a look at it.
I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB(64) vs. (Open)COMAL?
« Reply #2 on: December 28, 2018, 06:36:21 pm »
If you look at the sample program, it has almost no relation to BASIC.

// for remarks instead of REM or ‘
DIV for division instead of /

Quote
      370       WHILE a$(LEN(a$):LEN(a$))=" " DO a$:=a$(1:LEN(a$)-1)

I don’t even have a clue how to interpret that.

LEN(a$) should be a number, but what operation is the colon (:)??   

There’s also no WEND or LOOP statements....



Not saying it’s a BAD language at all — I don’t know it really.  I’m just saying it doesn’t resemble BASIC at all, to me.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline blametroi

  • Newbie
  • Posts: 26
    • View Profile
Re: QB(64) vs. (Open)COMAL?
« Reply #3 on: December 28, 2018, 07:51:14 pm »
Code: QB64: [Select]
  1. 370       WHILE a$(LEN(a$):LEN(a$))=" " DO a$:=a$(1:LEN(a$)-1)

I don’t even have a clue how to interpret that.

LEN(a$) should be a number, but what operation is the colon (:)??   

After a pause, I figured this intends to remove any trailing blanks from the string a$, so a$(LEN(A$):LEN(A$)) is a MID$, or RIGHT$ as most of us would write it. I'm not sure what motivates the syntax, but a lot of languages confuse me in this regard. At least it doesn't appear to be designed to minimize typing at the expense of reading :)

Offline freetrav

  • Newbie
  • Posts: 45
    • View Profile
Re: QB(64) vs. (Open)COMAL?
« Reply #4 on: December 28, 2018, 11:17:56 pm »

Quote
      370       WHILE a$(LEN(a$):LEN(a$))=" " DO a$:=a$(1:LEN(a$)-1)

I don’t even have a clue how to interpret that.

LEN(a$) should be a number, but what operation is the colon (:)??   

Array substring notation - A$(1:3) is like MID$(A$,1,3)

There’s also no WEND or LOOP statements....

WEND = ENDWHILE. I'd have to check the docs, not handy at the moment, but I think COMAL has REPEAT...UNTIL instead of LOOP


Offline blametroi

  • Newbie
  • Posts: 26
    • View Profile
Re: QB(64) vs. (Open)COMAL?
« Reply #5 on: December 29, 2018, 06:11:59 am »
After yesterday's post I followed a few links and saw some screenshots of code in their IDE and from that perspective I see a "bit of basic, dash of pascal". It looks to me as if the experience programming would be similar to basic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: QB(64) vs. (Open)COMAL?
« Reply #6 on: December 29, 2018, 07:00:45 am »
My thinking about this:

1.  Merging QB to Pascal or TurboPascal?
2.  FOR the same  logic issue is possible the double syntax QB AND Pascal  or only one?
  2.1 The choice is made 
                        A) at random,
                        B) following personal preferences of producer
                        C) a real advantage  of performance using QB or Pascal statement for the issue
                        D) a real advantage of easyness to read/write/remember  using QB or Pascal statement vs the other
(DO...LOOP UNTIL  vs REPEAT UNTIL)
3. Are data Type merged or ( as for keywords ) the producer has followed an own rule to choice what to do?
I.e. a string in QB is what lives between two CHR$(34) and in TPascal between two CHR$(39), in original Pascal string is a special array of type char[] that you can manage only as array while in TPascal you can use it as a simple variable or an array of char [].
4. Uh ...Are the number of line necessary?
Code: QB64: [Select]
  1. 10 // General sample program
  2.       20 //
  3.       30 WHILE NOT(EOD) DO
  4.       40   READ a
  5.       50   PRINT a;"  ";verbaal$(a)
  6.       60 ENDWHILE
  7.       70 //
  8.       80 DATA 1, 12, 34, 112, 1009, 1234567890
  9.       90 //
  10.      100 FUNC verbaal$(getal#) CLOSED
  11.      110   //
  12.      120   //   ************************************
  13.      130   //   **    FUNC Verbaal$ ( Integer )   **
  14.      140   //   ************************************
  15.      150   //
  16.      160   // Geschreven door Jos Visser, 25-06-1987
  17.      170   // Aangepast voor PDCOMAL,     10-9-92
  18.      180   //
  19.      190   //
  20.      200   // Functie :
  21.      210   //            Deze functie neemt als parameter een integer getal,
  22.      220   //            positief danwel negatief, en geeft een string terug
  23.      230   //            die weergeeft hoe dat getal op zijn Nederlands
  24.      240   //            geschreven kan worden.
  25.      250   //
  26.      260   // Parameters in :
  27.      270   //            Integer getal
  28.      280   //
  29.      290   // Parameters uit :
  30.      300   //            String, maximaal 132 karakters lang
  31.      310   //
  32.      320   // Packages ed.   :
  33.      330   //            Geen
  34.      340   //
  35.      350   PROC skipspaces(REF a$) CLOSED
  36.      360     IF a$<>"" THEN
  37.      370       WHILE a$(LEN(a$):LEN(a$))=" " DO a$:=a$(1:LEN(a$)-1)
  38.      380     ENDIF
  39.      390   ENDPROC
  40.      400   //
  41.      410   FUNC cijfer$(nr#) CLOSED
  42.      420     DIM a$ OF 5
  43.      430     a$:="nul  een  twee drie vier vijf zes  zevenacht negentien   "(1+nr#*5:5+nr#*5)
  44.      440     skipspaces(a$)
  45.      450     RETURN a$
  46.      460   ENDFUNC
  47.      470   //
  48.      480   FUNC t'11'19$(nr#) CLOSED
  49.      490     DIM a$ OF 10
  50.      500     a$:="tien     elf      twaalf   dertien  veertien vijftien zestien  zeventienachtien  negentien"(1+(nr#-10)*9:9+(nr#-10)*9)
  51.      510     skipspaces(a$)
  52.      520     RETURN a$
  53.      530   ENDFUNC
  54.      540   //
  55.      550   FUNC tiental$(nr#) CLOSED
  56.      560     DIM a$ OF 10
  57.      570     nr#:=nr# DIV 10
  58.      580     a$:="twintig dertig  veertig vijftig zestig  zeventigtachtig negentig"(1+(nr#-2)*8:8+(nr#-2)*8)
  59.      590     skipspaces(a$)
  60.      600     RETURN a$
  61.      610   ENDFUNC
  62.      620   //
  63.      630   FUNC duizend$(nr#) CLOSED
  64.      640     honderd#:=nr# DIV 100
  65.      650     rest#:=nr# MOD 100
  66.      660     IF honderd#>1 THEN
  67.      670       result$:=cijfer$(honderd#)+"honderd"
  68.      680     ELIF honderd#=1
  69.      690       result$:="honderd"
  70.      700     ELSE
  71.      710       result$:=""
  72.      720     ENDIF
  73.      730     IF rest#<=10 THEN
  74.      740       IF rest#<>0 OR honderd#=0 THEN result$:+cijfer$(rest#)
  75.      750     ELIF rest#<20
  76.      760       result$:+t'11'19$(rest#)
  77.      770     ELSE
  78.      780       IF rest# MOD 10<>0 THEN result$:=result$+cijfer$(rest# MOD 10)+"en"
  79.      790       IF rest# DIV 10>0 THEN result$:+tiental$(rest#)
  80.      800     ENDIF
  81.      810     RETURN result$
  82.      820   ENDFUNC
  83.      830   //
  84.      840   DIM result$ OF 132, subresult$ OF 40
  85.      850   result$:=""
  86.      860   IF getal#<0 THEN
  87.      870     negatief#:=TRUE
  88.      880     getal#:=-getal#
  89.      890   ELSE
  90.      900     result$:=""
  91.      910     negatief#:=FALSE
  92.      920   ENDIF
  93.      930   FOR macht#:=9 DOWNTO 0 STEP 3 DO
  94.      940     subgetal#:=getal# DIV 10^macht#
  95.      950     getal#:=getal# MOD 10^macht#
  96.      960     IF subgetal#>0 OR (macht#=0 AND result$="") THEN
  97.      970       subresult$:=duizend$(subgetal#)
  98.      980       IF macht#<>3 OR subgetal#<>1 THEN
  99.      990         result$:=result$+", "+subresult$
  100.     1000       ELSE
  101.     1010         IF result$="" THEN result$:="  "
  102.     1020       ENDIF
  103.     1030       CASE macht# OF
  104.     1040       WHEN 9
  105.     1050         result$:+" miljard "
  106.     1060       WHEN 6
  107.     1070         result$:+" miljoen "
  108.     1080       WHEN 3
  109.     1090         result$:+"duizend "
  110.     1100       OTHERWISE
  111.     1110         NULL
  112.     1120       ENDCASE
  113.     1130     ENDIF
  114.     1140     skipspaces(result$)
  115.     1150   ENDFOR
  116.     1160   result$:=result$(3:)
  117.     1170   IF negatief# THEN result$:="min "+result$
  118.     1180   RETURN result$
  119.     1190 ENDFUNC
  120.     1200 //

looking at this demo code
declaration of SUB and FUNCTION are those of TPascal, it is possible to nest Function AND/OR SUB , the case issue uses TPascal syntax, declaration of variable seems to be mixed mode QB+Pascal, operator for assignment  is Pascal etc etc etc
Programming isn't difficult, only it's  consuming time and coffee

Offline freetrav

  • Newbie
  • Posts: 45
    • View Profile
Re: QB(64) vs. (Open)COMAL?
« Reply #7 on: January 02, 2019, 08:38:02 am »
My thinking about this:

1.  Merging QB to Pascal or TurboPascal?

Probably Pascal, not Turbo Pascal; I remember seeing COMAL running on Commodore PETs or SuperPETs, and I think that predated Turbo Pascal even for CP/M. OTOH, Mr Visser did his first build of PDCOMAL/OpenCOMAL well after Turbo Pascal had more-or-less taken the Pascal marketplace on micros, so it seems likely that there was some at least indirect influence.

2.  FOR the same  logic issue is possible the double syntax QB AND Pascal  or only one?
  2.1 The choice is made 
                        A) at random,
                        B) following personal preferences of producer
                        C) a real advantage  of performance using QB or Pascal statement for the issue
                        D) a real advantage of easyness to read/write/remember  using QB or Pascal statement vs the other
(DO...LOOP UNTIL  vs REPEAT UNTIL)

Not quite sure what you're asking here.

3. Are data Type merged or ( as for keywords ) the producer has followed an own rule to choice what to do?
I.e. a string in QB is what lives between two CHR$(34) and in TPascal between two CHR$(39), in original Pascal string is a special array of type char[] that you can manage only as array while in TPascal you can use it as a simple variable or an array of char [].

String handling in COMAL appears to mostly follow the BASIC model rather than the Pascal model; the substring notation suggests, though, that under some circumstances a string can in fact be treated as an array of characters.

4. Uh ...Are the number of line necessary?

Yes. This is one of the biggest "downticks" that I had for both COMAL and Summit Software's BetterBASIC - the latter being another evolution of GW-BASIC toward structured programming, in a different direction from COMAL or QB.
« Last Edit: January 02, 2019, 08:48:06 am by freetrav »

Offline phred

  • Newbie
  • Posts: 11
    • View Profile
Re: QB(64) vs. (Open)COMAL?
« Reply #8 on: January 02, 2019, 11:00:04 am »
The string functions resemble True Basic's, (and Decimal Basic's), where a$(1:5) returns the first 5 characters.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: QB(64) vs. (Open)COMAL?
« Reply #9 on: January 02, 2019, 07:19:09 pm »
Thanks for these more informations
Programming isn't difficult, only it's  consuming time and coffee