Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:16 13 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMBasic for DOS. Error Array Dimensions

Author Message
hkoetz
Newbie

Joined: 30/03/2019
Location: Netherlands
Posts: 19
Posted: 03:50pm 13 Jul 2019
Copy link to clipboard 
Print this post

MMBasic for DOS version 5.05.01. Error: Array Dimensions

I get the following eror message




Sub saveGame()
Local loc as Integer, ext as Integer, obj As Integer, prp As Integer, evt As Integer, act As Integer
Open "SITS2.DAT" For Output As #1
Print #1, curLoc
For loc = 1 To maxLoc
For ext = 1 to maxLocExt
Print #1, locExt(loc,ext)e
Next ext
Next loc
For obj = 1 To maxObj
For prp = 1 to maxObjPrp
Print #1, objPrp(obj,prp)
Next prp
Next obj
For evt = 1 To maxEvt
For act = 1 to maxEvtAct
Print #1, evtAct(evt,act)
Next act
Next evt
Close #1
End Sub

Sub loadGame()
Local loc as Integer, ext as Integer, obj As Integer, prp As Integer, evt As Integer, act As Integer
Local crLc$, locExit$, objPrp$, evtAct$
Open "SITS2.DAT" For Input As #1
Line Input #1, crLc$ : curLoc = Val(crLc$)
For loc = 1 To maxLoc
For ext = 1 to maxLocExt
Line Input #1, locExit$ : locExt(loc,ext) = Val(locExit$)
Next ext
Next loc
For obj = 1 To maxObj
For prp = 1 to maxObjPrp
Print "obj, prp=", obj, prp
Line Input #1, objPrp$
Print "objPrp$=", objPrp$
objPrp(obj,prp) = Val(objPrp$) Error occurs here
Next prp
Next obj
For evt = 1 To maxEvt
For act = 1 to maxEvtAct
Line Input #1, evtAct$
evtAct(evt,act) = Val(evtAct$) and here
Next act
Next evt
Close #1
End Sub



when executing the load routine in the code below. The save routine works flawlessly. I am baffled.

Print "obj, prp=", obj, prp and
Print "objPrp$=", objPrp$

give the expected variable values (see image).

Can anyone help

yours
Henk Koetzier

Edited by hkoetz 2019-07-15
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10572
Posted: 03:57pm 13 Jul 2019
Copy link to clipboard 
Print this post

You have identical variable names with different attributes

objPrp$ and objPrp(obj,prp)

In modern versions of MMbasic variable names and function names must be unique irrespective of type

In the code posted the two dimensional array objPrp(m,n) isn't defined at all. It could be a function or an array but in either case it conflicts with objPrp$ inside Sub loadGame()

Inside a function the parser first searches the LOCAL variables. In your case it finds objPrp which it knows is a simple string variable. But then it sees objPrp(obj,prp) which conflicts with the cardinality of objPrp$

Edited by matherp 2019-07-15
 
hkoetz
Newbie

Joined: 30/03/2019
Location: Netherlands
Posts: 19
Posted: 07:34pm 14 Jul 2019
Copy link to clipboard 
Print this post

Thx Matherp, renaming the string variables worked.

For the record objPrp(..) and evtAct(..) are defined as global arrays elsewhere in the program.

Yours
Henk KoetzierEdited by hkoetz 2019-07-16
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025