Author Topic: BCX v7.9.1 is available for download  (Read 252 times)


  • Administrator
  • Hero Member
  • *****
  • Posts: 1431
    • View Profile
BCX v7.9.1 is available for download
« on: July 11, 2022, 09:58:27 PM »
Hello Friends,

Here is BCX 7.9.1.   Many hours went into this, so I hope it will be useful to some of you.

I decided to upload a 32 bit and 64 bit version of 7.9.1 that were compiled using the
latest Embarcadero C++ compiler.  It consistently gives me the best performance.

There is quite a lot to the 7.9.1 revisions, so please take some time to familiarize.


2022/07/11       Changes in 7.9.1 from 7.9.0
Kevin Diggins  : 7.9.1 cannot be translated with 7.9.0.  Either use one of my provided 7.9.1
                 executables or compile 7.9.1 yourself using the included BC.C or BC.CPP.

Kevin Diggins  : Many of the auto-detection enhancements that went into 7.9.1 have collectively
                 led to a performance hit, meaning BCX may take a little longer to do its work.
                 Complexity comes at a cost.  But, unless you're running an old PC, you probably
                 won't notice the change. On my PC, translating BCX went from around 0.6 seconds
                 to 0.9 seconds. YMMV

Kevin Diggins  : This release might break some code. Specifically, if you have a STRING
                 ARRAY that references an element's secondary location by pointer, you
                 will need to make a minor modification using my new BYTE_AT() macro.
                 For example:

                           DIM A$[5]   : A$[3] = "FUN!"
                           IF  A$[3][0] = ASC("F")  THEN PRINT "TRUE"

                                   MUST BE CHANGED to:
                   IF BYTE_AT (A$[3][0]) = ASC("F") THEN PRINT "TRUE"

Kevin Diggins  : Implemented auto-detection of user FUNCTION datatypes, so those FUNCTIONS
                 can be used in PRINT statements without requiring their related SIGILS
                 Equally important, many hours went into sorting out how to make the
                 following example translate correctly.  You can place the CLASS above or
                 below SUB MAIN.  Likewise, you can change the location and order of
                 FUNCTIONS F3 and F4.  That was no small feat.  But I like it when we
                 can get our computers to make our coding a little bit easier. For example,
                 BCX 7.9.1 will automatically translate this to a .cpp file :

                 SUB MAIN
                   DIM RAW a AS TYPETEST 
                   PRINT a.F1()           ' Notice there are no sigils (!#$) in any
                   PRINT a.F2()           ' of these PRINT statements.  BCX now works
                   PRINT a.F3()           ' that out for you.  Of course, 7.9.1 is
                   PRINT F4()             ' 100% backwardly compatible, so if you
                   PRINT F5()             ' like using sigils (!#$), go for it.
                 END SUB                 

                 CLASS TYPETEST

                   FUNCTION F1 () AS SINGLE
                      FUNCTION = 1.123456
                   END FUNCTION

                   FUNCTION F2 () AS DOUBLE
                      FUNCTION = 1.23456789012345
                   END FUNCTION

                   FUNCTION F3 () AS STRING
                      FUNCTION = "STRING"
                   END FUNCTION
                 END CLASS

                 FUNCTION F4 AS STRING
                    FUNCTION = "Hello From F4"
                 END FUNCTION

                 FUNCTION F5$             ' <<< NOTICE the use of the "$" sigil
                   FUNCTION = "Hello From F5"
                 END FUNCTION

Kevin Diggins  : Added a simple FOR_EACH() / NEXT_EACH() mechanism to the BCX lexicon.
                 This only works on multi-dimensional, STATICALLY DIMENSIONED arrays. 
                 This was tested using string, single, double, and integer arrays.
                 FOR_EACH / NEXT_EACH loops can be nested.

                 The basic usage / format looks like this:

                 FOR_EACH (LoopLocalVariable, NameOfOneDimensionalArray)
                    PRINT " Value = ", NameOfOneDimensionalArray [LoopLocalVariable]
                    more statements .....
                 NEXT_EACH (LoopLocalVariable) ' < Must match the name in the FOR_EACH ()

                 >>> Do not "DIM" your LoopLocalVariable's ... they are DIM'ed automatically.
                 You must provide the same >NAME< of your >LoopLocalVariable< to each pair
                 of FOR_EACH() and NEXT_EACH() macros.

                 Here is an example showing a nested FOR_EACH loop:

                 DIM Numbers[3] AS SINGLE

                 Numbers[0] = 0.000
                 Numbers[1] = 1.111
                 Numbers[2] = 2.222

                 DIM Strings [3] AS STRING

                 Strings$[0] = "ZERO"
                 Strings$[1] = "ONE"
                 Strings$[2] = "TWO"

                 PRINT "Displaying the NUMERIC array ..."

                 FOR_EACH (ZZ, Numbers)
                      PRINT "Cell No.", ZZ, " Value = ", Numbers[ZZ]
                      FOR_EACH (YY, Strings)
                           PRINT "Now Showing a NESTED FOR_EACH LOOP: ", Strings[YY]
                      NEXT_EACH (YY)
                 NEXT_EACH (ZZ)

                 PRINT "Displaying the STRING array one more time ..."

                 FOR_EACH (HH, Strings$)
                       PRINT "Cell No.", HH,  " Value = ", Strings$[HH]
                 NEXT_EACH (HH)

                 Here is an example using a two (2) dimensional string array to
                 simulate a poor mans dictionary:

                 DIM Dict [10,10] AS STRING

                 FOR_EACH (iter, Dict)
                    Dict [iter, 1] = "Key"   + STR$(iter)
                    Dict [iter, 2] = "Value" + STR$(iter)
                 NEXT_EACH (iter)

                 FOR_EACH (iter, Dict)
                    IF Dict [iter, 1] = "Key 5" THEN PRINT "Found: ", Dict [iter, 2] : PRINT
                 NEXT_EACH (iter)

                 PRINT "Here are the complete contents" : PRINT

                 FOR_EACH (iter, Dict)
                    PRINT Dict [iter, 1] , "  ",  Dict [iter, 2]
                 NEXT_EACH (iter)


Kevin Diggins  : BCX now broadly accepts the "#" SIGIL when used as a file handle.
                 When BCX encounters, for example,  #MyFPvar, BCX simply removes the "#".
                 But when #1, #2, #3 (or any valid file number) is supplied, BCX will
                 convert those to: FP1, FP2, FP3, and so on.  BCX now watches all
                 file I/O functions and automatically transforms them when necessary.
                 For example, for the first time ever, the following is now valid in BCX:

                      OPEN "test.txt" FOR OUTPUT AS #1
                      PRINT #1, "this is a test"
                      FLUSH  #1
                      CLOSE #1
                      DIM a$

                      OPEN "test.txt" FOR INPUT AS #1
                      LINE INPUT #1, a$
                      PRINT a$
                      a$ = ""
                      SEEK #1, 0
                      LINE INPUT #1, a$
                      PRINT a$
                      SETEOF #1, 10
                      CLOSE #1

                      OPEN "test.txt" FOR APPEND AS #1
                      PRINT #1, "Here", " is", " new", " data"
                      CLOSE #1

                      OPEN "test.txt" FOR INPUT AS #1
                      WHILE NOT EOF(#1)
                         LINE INPUT #1, a$
                         PRINT a$
                      CLOSE #1

                      OPEN "test.txt" FOR BINARY AS #1
                      CLEAR a$
                      GET #1, a$, 8
                      CLOSE #1
                      PRINT a$, "GREAT!"

Kevin Diggins  : BCX now allows you to use QBASIC style file I/O.  FPRINT and FINPUT are
                 permanent BCX commands that you can continue to use as you always have.
                 The BCX Translator itself was tested using these new capabilities.

                 Below is a modified version of the BCX Help FINPUT example.  Notice how
                 BCX now allows PRINT #1, CLOSE #1, INPUT #1, and so on.  Notice also
                 that you don't need to include sigils on the INPUT or PRINT statements.

                      DIM P, N!, E#, L!, D$, j, random!
                      OPEN "TEST.TXT" FOR OUTPUT AS #1
                      FOR j = 1 TO 10
                         random! = j * 100.0 * RND
                         PRINT #1, j , ",", random!, ",", 12356789.012345#, ",", j + 10, ",", "This string has spaces"
                      CLOSE #1
                      OPEN "TEST.TXT" FOR INPUT AS #1
                      WHILE NOT EOF(#1)
                         INPUT #1, P, N, E, L, D
                         PRINT P, " ", N, " ", E, " ", L, " ", D
                      CLOSE #1

Kevin Diggins  : Enhanced the CLOSE statement by allowing multiple file handles on one line.
                 For example:   CLOSE #1, #2, FP3, MyDocHandle

Kevin Diggins  : Improved the translation of the OPTION BASE statement.

Kevin Diggins  : Added $PRAGMA to the built-in directives.  For example, used within BCX 791:

                      $IFDEF (__GNUC__)
                          $PRAGMA GCC diagnostic ignored "-Wcast-function-type"
                           PPProc = (CPP_FARPROC) GetProcAddress (PPDLL_HANDLE,"ProcessLine");
                          $PRAGMA GCC diagnostic pop
                          PPProc = (CPP_FARPROC) GetProcAddress (PPDLL_HANDLE,"ProcessLine");

Kevin Diggins  : Added "COMSET" reserved word as an alias to "SET", to overcome formatting
                 issues when using the "SET" OBJECT keyword in certain code editors.

Kevin Diggins  : Added VBA's "FILECOPY" reserved word as alias to BCX's "COPYFILE" statement.

Kevin Diggins  : Added VBA's "GET" and "PUT" as aliases to BCX's "GET$" AND "PUT$" statementa.

Kevin Diggins  : Improved C++ detection.  When certain C++ keywords are detected, BCX outputs
                 a *.cpp file automatically.  The 35 C++ samples found in the BCX Help file
                 were used to test BCX's auto-detection.  Neither $CPP nor the -cpp switch
                 were needed or used for the correct translation.

Kevin Diggins  : String functions within PPTYPES did not emit storage for BCX_RetStr.  Fixed

Kevin Diggins  : Re-worked the following directives to be less confusing:

                 $WARNINGS         ' ENABLE  C/C++ compiler warnings. ( Deprecated )
                 $WARNINGS_ON      ' ENABLE  C/C++ compiler warnings.
                 $WARNINGS_OFF     ' DISABLE C/C++ compiler warnings  ( Default )
Kevin Diggins  : Ongoing formatting improvements to the source, output and runtime code

« Last Edit: July 11, 2022, 10:11:33 PM by MrBcx »