QuickBasic and Windows XP

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Pipeliner
Newbie
Posts: 8
Joined: Mon Feb 18, 2013 5:32 pm

QuickBasic and Windows XP

Post by Pipeliner »

Hi, I'm a new poster to this forum.

back in the 1980's I wrote a number of programs in QB45 which are related to my work (gas pipelines) and which I still use today as I haven't yet found anything which works better! Each program has a subroutine called GetGas which searches C:\CHPROGS for files with the extension *.GAS and sorts the names into a file which can then be read to allow a particular gas composition to be used in the rest of the program. The *.exe version of each program has run perfectly up to date in all versions of Windows up to XP.

Recently (possibly after a new XP service pack was installed, but not sure about that) each time the program gets to GetGas in starts looking for the stored *.GAS files the computer throws up the error message "Not enough memory to complete the sort". There is certainly plenty of memory available on the machine, so it must be something to do with the way XP is allocating resources.

Any ideas, anyone? The relevant section of the QB45 code seems to be

LOCATE 16, 15: INPUT GasFileDir$: IF GasFileDir$ = "" THEN GasFileDir$ = DefaultDir$
FOR i = 6 TO 16 STEP 2
LOCATE i, 15: PRINT " "
NEXT i
MissHead:
'SHELL "cd " + GasFileDir$
SHELL "dir " + GasFileDir$ + "\*.gas|sort>" + GasFileDir$ + "\gasfiles.dir"
OPEN GasFileDir$ + "\gasfiles.dir" FOR INPUT AS #1
j = 1
DO UNTIL EOF(1)
LINE INPUT #1, FileName$
FOR i = 1 TO 10
IF MID$(FileName$, i, 1) = " " AND MID$(FileName$, 10, 3) = "GAS" THEN
GasFile$(j) = LEFT$(FileName$, i - 1)
j = j + 1
EXIT FOR
END IF
NEXT i
LOOP
CLOSE #1
j = j - 1
FOR i = 1 TO j
OPEN GasFileDir$ + "\" + GasFile$(i) + ".GAS" FOR INPUT AS #1
INPUT #1, FileHead$(i)
CLOSE #1
NEXT i
GOSUB header
CALL Cenprint(5, "Gases on File", 4)
disp: COLOR 13
FOR i = 1 TO 10
IF i + inc > j THEN EXIT FOR
LOCATE 5 + i, 10
PRINT CHR$(i + 64) + ") " + FileHead$(i + inc)
NEXT i
GOSUB endpage
IF inc > j THEN inc = inc - 10
GOTO disp
endpage:


Mind you, it's so long since I wrote it that I'm not sure I understand what it all means any more: I just know it used to work!

Thanks
Chris
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Try running it on QB64. It can run Qbasic code on any Windows machine from XP up. Also Linus and Mac OSX.

You may want to add _HIDE after SHELL in the command lines.

See the link below
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Pipeliner
Newbie
Posts: 8
Joined: Mon Feb 18, 2013 5:32 pm

Post by Pipeliner »

Thanks, I'll give that a try.
Pipeliner
Newbie
Posts: 8
Joined: Mon Feb 18, 2013 5:32 pm

Post by Pipeliner »

Ok, I downloaded QB64 and opened ONEPIPE.BAS and pressed 'RUN' and got the error message 'Line 354 Subscript out of range' - the same message for lines 355,357, 358 & 359. QB45 does not produce this error. The code in question is

341 SUB Combin
342 '**Combining rules for mixing interaction terms**
343 DIM gamb(12), epsb(12), sigb(12), U(12, 12), v(12, 12), w(12, 12)
344 RESTORE epsdata: FOR i = 1 TO 12: READ epsb(i): NEXT i
345 RESTORE sigdata: FOR i = 1 TO 12: READ sigb(i): NEXT i
346 RESTORE gamdata: FOR i = 1 TO 12: READ gamb(i): NEXT i
347 RESTORE newu: FOR i = 1 TO 12: FOR j = i TO 12: READ U(i, j): U(j, i) = U(i, j): NEXT j: NEXT i
348 RESTORE newv: FOR i = 1 TO 12: FOR j = i TO 12: READ v(i, j): v(j, i) = v(i, j): NEXT j: NEXT i
349 RESTORE neww: FOR i = 1 TO 12: FOR j = i TO 12: READ w(i, j): w(j, i) = w(i, j): NEXT j: NEXT i
350
351 alp = 1 / 3
352 FOR j = 1 TO 12
353 FOR k = 1 TO 12
354 bsij(j, k) = SQR(sigb(j) * sigb(k)) ^ alp
355 sij(j, k) = v(j, k) * bsij(j, k)
356 epsij = SQR(epsb(j) * epsb(k))
357 eij(j, k) = U(j, k) * epsij
358 beij(j, k) = w(j, k) * epsij
359 gij(j, k) = (gamb(j) + gamb(k)) / 2
360 NEXT k
361 NEXT j
362 ERASE gamb, epsb, sigb, U, v, w
363 END SUB


Any thoughts? (NB: the code does not have line numbers - I added them just now to locate where the problem was)
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Subscript out of range means that an array is not big enough or the program is reading beyond the array limits. Are any of the array sizes set by a file?

Make sure all of the SHELL and OPEN calls work properly! If you want me to check the code send it with the files it will need.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Pipeliner
Newbie
Posts: 8
Joined: Mon Feb 18, 2013 5:32 pm

Post by Pipeliner »

Thanks. Email sent.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

OK, you don't need COMMON when using SHARED and you can do that with DIM. COMMON is used for multiple modules to pass values.

Code: Select all

DIM SHARED Component$(12), X(12)
   
DIM SHARED a(12), M(12)
   

'The following parameters are calculated from the above data
'in subroutine COMBIN and are used in the AGA 8 equations
   
DIM SHARED bsij(12, 12), sij(12, 12), eij(12, 12)
DIM SHARED gij(12, 12), beij(12, 12)
Change the array portion as shown above. QB64 doesn't like COMMON after DIM.

I also noticed variables named a1, a2, etc. You could use an array to set the values instead of using CONST, but that is up to you:

a(1) = ?????: a(2) = ????

They won't change unless the program changes them.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Pipeliner
Newbie
Posts: 8
Joined: Mon Feb 18, 2013 5:32 pm

Post by Pipeliner »

Thanks for that. I'll try it next time I'm in the office and let you know how it goes.
Pipeliner
Newbie
Posts: 8
Joined: Mon Feb 18, 2013 5:32 pm

Post by Pipeliner »

OK, I fixed the DIM SHARED problem and that part works fine now, but the problem noted in my original post is still there. When I try to run that bit I get a black DOS screen flash up - it comes and goes too fast to see whether it contains an error message.

What I think is supposed to happen (bearing in mind it is at least 25 years since I wrote it!) is:

LOCATE 16, 15: INPUT GasFileDir$: IF GasFileDir$ = "" THEN GasFileDir$ = DefaultDir$
This allows the user to select the directory where the *.GAS files are stored: the default directory is C:\CHPROGS.

SHELL "dir " + GasFileDir$ + "\*.gas|sort>" + GasFileDir$ + "\gasfiles.dir"
OPEN GasFileDir$ + "\gasfiles.dir" FOR INPUT AS #1
j = 1
DO UNTIL EOF(1)
LINE INPUT #1, FileName$
FOR i = 1 TO 10
IF MID$(FileName$, i, 1) = " " AND MID$(FileName$, 10, 3) = "GAS" THEN
GasFile$(j) = LEFT$(FileName$, i - 1)
j = j + 1
EXIT FOR
END IF
NEXT i
LOOP
CLOSE #1
What this does is look in GasFileDir$ for all files with a *.GAS extension, and list them alphabetically into a new file called gasfiles.dir . It also loads the corresponding description FileName$ (which is part of the *.gas file) into an array.

CALL Cenprint(5, "Gases on File", 4)
disp: COLOR 13
FOR i = 1 TO 10
IF i + inc > j THEN EXIT FOR
LOCATE 5 + i, 10
PRINT CHR$(i + 64) + ") " + FileHead$(i + inc)
NEXT i

This is supposed to list the available gases in groups of 10: it is at this point that, as far as the screen display is concerned, the whole thing falls down. The first line works just fine, but after that there is nothing displayed on the screen. It just drops down to
COLOR 14: LOCATE 16, 30: PRINT "Press the corresponding letter"
LOCATE 17, 30: PRINT "to select one of these gases,"
LOCATE 19, 30: PRINT "Press [Spacebar] to enter a new gas"
IF GasFile$(i + inc + 1) <> "" THEN LOCATE 21, 30: PRINT "or press [2] for more file gases"

and by hitting Spacebar I can manually enter a gas and the whole thing works fine from then on.

All suggestions gratefully received!

Chris
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

If you don't want to see the DOS window, just use SHELL _HIDE "command line here"

If SHELL _HIDE isn't working try adding CMD /C at start of command line.

I don't have that file either. My advise is to get rid of all paths and work with everything in one place until the bugs are ironed out.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Pipeliner
Newbie
Posts: 8
Joined: Mon Feb 18, 2013 5:32 pm

Post by Pipeliner »

It's not a matter of not wanting to see the DOS window, it's that it doesn't seem to want to list the available *.gas files.

If I run the code in QB4.5 I have the option to run an interpreter which allows me to see what is happening as the code runs through line by line: is there any similar feature available in QB64?
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

QB64 makes the DIR file, but they are not displayed:
Volume in drive C has no label.
Volume Serial Number is E8AA-BB3C

Directory of C:\Documents and Settings\Ted\Basic64\qb64

02/19/2013 12:47 AM 76 COMRIDGE.GAS
02/19/2013 12:47 AM 156 EGPSTD.GAS
02/19/2013 12:47 AM 139 Ggtdesn.gas
02/19/2013 12:47 AM 83 Gilmore3.gas
02/19/2013 12:47 AM 86 MACEDON.GAS
02/19/2013 12:47 AM 78 Moomay89.gas
02/19/2013 12:47 AM 163 Palmvall.gas
7 File(s) 781 bytes
0 Dir(s) 17,224,544,256 bytes free
I took out the folder paths to do that.


Might I suggest "DIR /b *.gas > gasfiles.dir". That will just list the files. Then you can simplify the read code.

Code: Select all

SUB GetGas STATIC
DIM GasFile$(100), FileHead$(100)
inc = 0
DefaultDir$ = "" '??????????
IF GasGrav > 0 THEN GOTO MissHead
GOSUB header
COLOR 15: LOCATE 6, 15: PRINT "Before running any programs you must select a gas"
LOCATE 8, 15: PRINT "to be used in the flow equations. The gas selected"
LOCATE 10, 15: PRINT "can be changed at any time if necessary."
COLOR 14
LOCATE 12, 15: PRINT "Enter path to directory where gas analysis files are stored"
LOCATE 14, 15: PRINT "or press [Enter] to accept default of ";: COLOR 15: PRINT DefaultDir$
LOCATE 16, 15: INPUT GasFileDir$: IF GasFileDir$ = "" THEN GasFileDir$ = DefaultDir$
FOR i = 6 TO 16 STEP 2
  LOCATE i, 15: PRINT "                                                            "
NEXT i
MissHead:
'SHELL "cd " + GasFileDir$
SHELL _HIDE "dir /b *.gas > gasfiles.dir" '<<<<<<<<<path?
OPEN "gasfiles.dir" FOR INPUT AS #1      '<<<<<<<<<path?
j = 1
DO UNTIL EOF(1)
  LINE INPUT #1, FileName$
  GasFile$(j) = FileName$
  j = j + 1
LOOP
CLOSE #1

FOR i = 1 TO j
  OPEN GasFile$(i) FOR INPUT AS #1
  INPUT #1, FileHead$(i)
  CLOSE #1
NEXT i
GOSUB header
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Pipeliner
Newbie
Posts: 8
Joined: Mon Feb 18, 2013 5:32 pm

Post by Pipeliner »

Thanks, I'll give that a try.
Post Reply