Multidimensional arrays as parameters

Just starting out? Need help? Post your questions and find answers here.
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Multidimensional arrays as parameters

Post by Sicro »

Code: Select all

Procedure Test(Array paramArray(1,1))
    paramArray(0,1) = 10
EndProcedure

Dim testArray(1,1)
Test(testArray())
Debug testArray(0,1)
[COMPILER] Line 1: Syntax error.
This should be mentioned in the description of the procedure block.
Last edited by Sicro on Sat Oct 26, 2019 12:58 pm, edited 1 time in total.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Multidimensional arrays are not supported as parameters

Post by #NULL »

You have to specify the number of dimensions, not the size of each dimension:

Code: Select all

Procedure test(Array paramArray(2))     ; 2 dimensions
    paramArray(1,1) = 10
EndProcedure

Dim testArray(1,1)
test(testArray())
Debug testArray(1,1)
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: [My mistake] Multidimensional arrays as parameters

Post by Sicro »

Thanks. I was confused and too hasty.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: [My mistake] Multidimensional arrays as parameters

Post by #NULL »

No problem. It's only 'documented' :) in the comments of example codes for Dim/Array and Procedure.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2058
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: [My mistake] Multidimensional arrays as parameters

Post by Andre »

I would close this bug-report. Or do you still have suggestions for better documentation about this topic?

When I look in the PB manual, I can read in the 'Procedure' section, that Arrays can be given a procedure paramenter with the Array keyword. And in the linked 'Array' chapter there is mentioned the correct use including code example.... or?
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply