'Invalid variable name error in QB64 with old QuickBasic code

I am trying to run a QuickBasic file written by someone else in 1992. I am using QB64 on a Windows 10 machine. I get an error message that says Invalid variable name in line 26 of the following code. Lines 1-31 are below, but here is line 26 in isolation.

COMMON SHARED /rgraph/ absxmin(), absymin(), absxmax(), absymax()

I tried changing the names of absxmin(), absymin(), absxmax(), absymax() to various things but the error message always appeared. Then I tried removing line 26 and I got the same error message for the next line.

COMMON SHARED /rgraph/ uxmin(), uymin(), uxmax(), uymax(), shrinkl(), shrinkr()

Here are lines 1-31. When people use the code, which came with a book, people are asked to attribute it. So, the code was written by Ray Hilborn, I believe.

DECLARE SUB zGraphInit (ScreenNumber#)
DECLARE SUB zLabelX (ig!, label$)
DECLARE SUB zLabelY (ig!, ylabel$)
DECLARE SUB hess (popt#(), h#(), r#(), sigma#, npar!, npts!, lu!)
DECLARE SUB CallFlet ()
DECLARE SUB UserPlot (itn!, f#, n!, x#())
DECLARE SUB zClearTotalScreen ()
DECLARE SUB waitsub ()
DECLARE SUB InitGraphs ()
DECLARE SUB zGrid (ig!, xtics#, ytics#)
DECLARE SUB zCursor (ig!, x#, y#, irow!, icol!)
DECLARE SUB zScale (ig!, axs#, ays#, axl#, ayl#, uxs#, uys#, uxl#, uyl#, shl#, shr#)
DECLARE SUB mnmx (x#(), n!, xmin#, xmax#)
DECLARE SUB zGraphView (ig!)
DECLARE SUB flet (f#, x#(), n!, g#(), h#(), dfn#, xm#(), hh#, eps#, mode!, maxfn!, iprint!, w#(), iexit!)
DECLARE FUNCTION func# (x#(), n!)
DECLARE SUB printstats (xtime#, itn!, ifn!, f#, n!, x#(), g#())
DECLARE FUNCTION NormDev! ()
DECLARE FUNCTION xmed# (x#(), n!)
DECLARE SUB zLocate (irow!, icol!)
DECLARE SUB InputData ()
DEFDBL A-H, O-Z

DIM absxmin(10), absymin(10), absxmax(10), absymax(10), absperux(10), absperuy(10)
DIM uxmin(10), uymin(10), uxmax(10), uymax(10), shrinkl(10), shrinkr(10)
COMMON SHARED /rgraph/ absxmin(), absymin(), absxmax(), absymax()
COMMON SHARED /rgraph/ uxmin(), uymin(), uxmax(), uymax(), shrinkl(), shrinkr()
COMMON SHARED /rgraph/ screenxdots, screenydots, absperux(), absperuy()

COMMON SHARED IprintResid, iprint, Idebug

Thank you for any help in resolving this error message.



Solution 1:[1]

A friend told me how to get the QBasic file running. Here are his instructions slightly edited. Essentially you need to install an MS-DOS emulator and a version of QBasic, here QB45. Some of the following is specific to the file in my original post, but the instructions can probably be generalized to many old QBasic files.

  1. Download an MS-DOS emulator (DOSBOX, https://sourceforge.net/projects/dosbox/files/latest/download)

  2. Download a version of QBASIC (https://www.qbasic.net/en/qbasic-downloads/DOS/Windows-Solutions.htm). (I downloaded the first of the two suggested solutions: Basic 2 DOSBox)

  3. Install dosbox, but when it asks where to install it, put it in c:\pgms\dosbox (not c:\Program Files (x86)\DOSBox-0.74-3). The old ms-dos operating system doesn’t like long filenames or filenames with spaces in them.)

  4. Paste the QB45 folder (obtained when unzipping the file in Step 2) in c:\pgms\dosbox\

  5. Locate dosbox.exe (from Step 1) and double-click it. That should open a black window with a prompt, Z:\>.

  6. In that window, type mount c c:\pgms\dosbox.

  7. Also type mount d c:\users\mark_\disk where chap11 is a subfolder in that folder. The folder disk and the subfolder chap11 are specific to the QBasic file in my original post.

  8. Type d:

  9. Type cd chap11

  10. Type c:\qb45\qb d:\chap11\catch1.mak

That should load qbasic with the CATCH1.BAS and 3 other basic programs needed. The program CATCH1.BAS will be displayed on the screen.

  1. Run the program by hitting Alt-R, Enter.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark Miller