Syntax Error in using Arrays as arguments

Just starting out? Need help? Post your questions and find answers here.
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Syntax Error in using Arrays as arguments

Post by offsides »

PB says I have a "Syntax error in the procedure arguments", but I can't figure it out.

Code: Select all

; Checking if two arrays are the same

EnableExplicit
Define.i i, Size1, Size2, Equal
; -----------------------------------------

; Begin
Dim FirstArray.i(9)
Dim SecondArray.i(9)

For i = 0 To 9
  FirstArray(i) = i
  SecondArray(i) = i
Next

FirstArray(3) = 88    ; Make "3" different

For i = 0 To 9
  Debug FirstArray(i)
  Debug SecondArray(i)
  Debug "------"
Next

; -------------------------------------------------
Procedure ArrayIsEqual(Array1(), Array2())
  Size1 = ArraySize(Array1()) 
  Size2 = ArraySize(Array2())   
  
  If Size1 = Size2                  ; Check if same # elements
    Equal = #True
    For i = 0 To Size1
      If Array1(i) <> Array2(i)     ; ...then compare each element.
        Equal = #False
        Break
      EndIf
    Next
  EndIf
  ProcedureReturn Equal
EndProcedure
; -------------------------------------------------

Debug ArrayIsEqual(FirstArray(), SecondArray())
__________________________________________________
Code tags repaired
04.05.2019
RSBasic
PB 5.72 (32-bit) on Win 10.
User avatar
skywalk
Addict
Addict
Posts: 4003
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Syntax Error in using Arrays as arguments

Post by skywalk »

Procedure ArrayIsEqual(Array Array1(1), Array Array2(1))
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Syntax Error in using Arrays as arguments

Post by Olliv »

The digit (1) is the quantity of dimensions.
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Re: Syntax Error in using Arrays as arguments

Post by offsides »

Thanks, skywalk & Olliv. Missed that.

Bill
PB 5.72 (32-bit) on Win 10.
Post Reply