Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP TO RUN QBASIC CODE FROM 90s !
#1
Hello everyone, I am having a hard time trying to run a code, (which I copied and pasted from a PDF text book ^^), 
The program was written in Microsoft QuickBASIC for Apple Macintosh, so i investigated a little and   
close to that i found QB64 programing languaje , i dont know if the syntax is the same, but the file (.bas), gets executed,
 
If someone can help me resolve the problem, I would appreciate it. ♥
I am leaving the link to the GitHub repository if you want to download the files and try them out yourselves.
its strange because the code is from a book, So it shouldn't be an issue ! 
I am also attaching a video with two images, showing what happens when I try to run the code completely! 

link to github :
https://github.com/musss1s/programingQBASIC.git

first image : 
The main program, calls the file "uflo.dat",which i highlighted in yellow, it stores numbers in a 21x41 array format, 
with 21 columns and each column containing 41 numbers, separated by commas. 
I = 21 and J = 41.
 
It is used to perform some calculations for sonic and subsonic flow, "gas dynamics."
[Image: c02dd121885ba3e20f76be7cdc10603c.png]


second image:
i marked in red where the syntaxis problem is 
[Image: b9484f8039912bc41a00b3747cc28810.png]

reference video:



the code should look like this :

[Image: 81ad2207c7346cfd0e26c4c84101d1b3.png]


please help !!! Sad   thank you guys
Reply
#2
hello musss1 Smile 
the error occurs in the Sub PORT, a subscript out of range occurs
I inserted some print statements
Code: (Select All)

Sub PORT (A, B, P, AK) Static
    Shared ABX(), BX(), AKA(), PA
    X1 = (P / PA) ^ (1 / 7)
    BX1 = B / X1
    If AK > .95 Then AK = .95
    If BX1 < .6 Then BX1 = .6
    I = Int(AK / .05) + 1
    J = Int((BX1 - .6) / .02) + 1
    Print "AK="; AK, "I="; I
    Print "J="; J
    RA = (AK - AKA(I)) / (AKA(I + 1) - AKA(I))
    AB1 = RA * (ABX(I + 1, J + 1) - ABX(I, J + 1)) + ABX(I, J + 1)
    AB2 = RA * (ABX(I + 1, J) - ABX(I, J)) + ABX(I, J)
    RB = (BX1 - BX(J)) / (BX(J + 1) - BX(J))
    ABX1 = RB * (AB1 - AB2) + AB2
    A = 2 * X1 * ABX1 - B
End Sub

this is the output
Quote:AK= .9 I= 18
J= 21
AK= .95 I= 19
J= 21
AK= .9 I= 18
J= 18
AK= 5.346714E-02 I= 2
J= 12
AK= nan I= nan
J=18
in the fifth call to Sub PORT AK and I are NaN, you obviously need to investigate why that happens
Reply
#3
On line 752:
Code: (Select All)
CALL FPORT(HTDC, HIOT, INHT, FIPRT, FIPRT, AKI, CCI)
FIPRT is set to 0 because it is never assigned a value. This leads to a division by 0 in FPORT which sets AKI to "not a number" which later on breaks the array access.

Perhaps the code was copied from the PDF wrongly? I had a quick look and couldn't see any FIPRT assignment though.
Reply
#4
I think that it's from the book "The Basic Design Of Two Stroke Engines" by Gordon P. Blair
http://offshore-rc.com/forum/Ancien%20Se...910089.pdf

I searched the web to see if by chance someone had posted the code but no luck
Reply
#5
Found an error here that differed from the printout. Its around line 77.

Code: (Select All)
GOSUB PORTSTART
INPUT "TYPE 'RUN' FOR CALCULATION OR 'NEW' FOR A DATA CHANGE: ", Z$
IF Z$ = "NEW" THEN GOTO 50

CALL PAREA(NEP, WEPM, EXHT, RTEM, RBEM, FEPRT, DEPRT)
CALL PAREA(NTP, WTPM, TRHT, RTTM, RBTM, FTPRT, DTPRT)
CALL PAREA(NIP, WIPM, INHT, RTIM, RBIM, FIPRT, DIPRT) '<---FIXED an Error Here
FTDUCT = TRAR * FTPRT
DTDUCT = SQR(4 * FTDUCT / PI)
TSV = FPISTON * HEOT
CYCV = TSV / (TCR - 1)
Reply
#6
@justsomeguy
your change made it work, but the graph doesn't match with the one in OP, perhaps that graph is from a different program or the data file differs
Reply
#7
I did not do an exhaustive search for typos, but since what I found was a typo, it implies that there could be more.
Reply
#8
(06-10-2024, 01:26 PM)Jack Wrote: I think that it's from the book "The Basic Design Of Two Stroke Engines" by Gordon P. Blair
http://offshore-rc.com/forum/Ancien%20Se...910089.pdf

I searched the web to see if by chance someone had posted the code but no luck
Hey, YES I left the code in the GitHub repository, and the pdf
but just in case it doesn't show up or something, I'll leave the Mega link here for you to check! thanks a lot !


https://mega.nz/file/Zh5AHTrB#bnscAhu5Zx...u12RAxt2pM
Reply
#9
In Line 333 you might adjust the 'LOCATE 25,28' -> 'LOCATE 25,33' because PMAX is overwritten by the following line.

Code: (Select All)
LOCATE 25, 1: PRINT "PEAK CYLINDER PRESS., bar="; USING "###.#"; PMAX
LOCATE 25, 33: PRINT "and TEMP., K="; USING "####."; TKMAX
LOCATE 25, 44: PRINT "at deg. ATDC="; USING "##.#"; MAXDEG
Reply
#10
Thumbs Up 
(06-10-2024, 04:13 PM)justsomeguy Wrote: In Line 333 you might adjust the 'LOCATE 25,28' -> 'LOCATE 25,33' because PMAX is overwritten by the following line.

Code: (Select All)
LOCATE 25, 1: PRINT "PEAK CYLINDER PRESS., bar="; USING "###.#"; PMAX
LOCATE 25, 33: PRINT "and TEMP., K="; USING "####."; TKMAX
LOCATE 25, 44: PRINT "at deg. ATDC="; USING "##.#"; MAXDEG
gotcha [Image: thumbsup.png]
Reply




Users browsing this thread: 5 Guest(s)