'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.
Download an
MS-DOSemulator (DOSBOX, https://sourceforge.net/projects/dosbox/files/latest/download)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)Install
dosbox, but when it asks where to install it, put it inc:\pgms\dosbox(notc:\Program Files (x86)\DOSBox-0.74-3). The oldms-dosoperating system doesn’t like long filenames or filenames with spaces in them.)Paste the
QB45folder (obtained when unzipping the file in Step 2) inc:\pgms\dosbox\Locate
dosbox.exe(from Step 1) and double-click it. That should open a black window with a prompt,Z:\>.In that window, type
mount c c:\pgms\dosbox.Also type
mount d c:\users\mark_\diskwherechap11is asubfolderin thatfolder. The folderdiskand thesubfolder chap11are specific to theQBasicfile in my original post.Type
d:Type
cd chap11Type
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.
- 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 |
