Line 36 Syntax error in the procedure arguments

Just starting out? Need help? Post your questions and find answers here.
Hanlov
New User
New User
Posts: 1
Joined: Mon Sep 23, 2024 9:08 pm

Line 36 Syntax error in the procedure arguments

Post by Hanlov »

I dont understand whats wrong in the code

Code: Select all

; Olyckstillfälle i PureBasic

Global Dim probabilities(12, 2) ; Matris för sannolikheter för 13 olyckor Global Dim previousRows(1000, 12) ; Max 1000 tidigare olyckor,  4 13 olyckor per rad Global previousRowCount = 0

Procedure RandomResult(prob1, probX, prob2)
  Protected rnd = Random(100)
  
  If rnd < prob1
    ProcedureReturn 1
  ElseIf rnd < prob1 + probX
    ProcedureReturn 0 ; X
  Else
    ProcedureReturn 2
  EndIf
EndProcedure

Procedure GenerateSingleRow(*row.Integer)
  For match = 0 To 12
    prob1 = probabilities(match, 0)
    probX = probabilities(match, 1)
    prob2 = probabilities(match, 2)
    PokeI(*row + match * SizeOf(Integer), RandomResult(prob1, probX, prob2))
  Next match
EndProcedure

Procedure CountSimilarities(*row1.Integer, *row2.Integer)
  Protected similarities = 0
  For i = 0 To 12
    If PeekI(*row1 + i * SizeOf(Integer)) = PeekI(*row2 + i * SizeOf(Integer))
      similarities + 1
    EndIf
  Next
  ProcedureReturn similarities
EndProcedure

Procedure GenerateTip(probabilities()) ; Ingen typ på rows eller maxSimilarities
  Protected rows, maxSimilarities
  rows = 1 ; Default värde
  maxSimilarities = 5 ; Default värde
  
  ; Skapa fönster för att få in data
  rows = InputRequester("Antal rader", "Ange olyckor rader att generera:", "1")
  maxSimilarities = InputRequester("Max lika matcher", "Ange max lika olyckor:", "5")
  
  Protected Dim newRow(12) ; Temporär array för en ny rad
  For row = 1 To Val(rows)
    Repeat
      GenerateSingleRow(@newRow())
      
      Protected similar = #False
      For i = 0 To previousRowCount - 1
        If CountSimilarities(@newRow(), @previousRows(i, 0)) > Val(maxSimilarities)
          similar = #True
          Break
        EndIf
      Next i
    Until Not similar
    
    ; Spara den genererade raden
    For match = 0 To 12
      previousRows(previousRowCount, match) = newRow(match)
    Next match
    previousRowCount + 1
    
    ; Visa raden
    For match = 0 To 12
      Select newRow(match)
        Case 1
          Debug "1"
        Case 0
          Debug "X"
        Case 2
          Debug "2"
      EndSelect
    Next match
    Debug "-----------------" ; Separera varje rad
  Next row
EndProcedure

If OpenWindow(0, 200, 200, 500, 600, "Olyckor")
  
  ; Skapa inmatningsfält för sannolikheter
  For match = 0 To 12
    TextGadget(#PB_Any, 10, 20 + (match * 30), 100, 20, "Match " + Str(match + 1) + " - 1:")
    probabilities(match, 0) = StringGadget(#PB_Any, 120, 20 + (match * 30), 50, 20, "33")
    
    TextGadget(#PB_Any, 180, 20 + (match * 30), 50, 20, "X:")
    probabilities(match, 1) = StringGadget(#PB_Any, 220, 20 + (match * 30), 50, 20, "33")
    
    TextGadget(#PB_Any, 280, 20 + (match * 30), 50, 20, "2:")
    probabilities(match, 2) = StringGadget(#PB_Any, 320, 20 + (match * 30), 50, 20, "33")
  Next match
  
  ; Knapp för att generera rader
  generateButton = ButtonGadget(#PB_Any, 200, 500, 100, 30, "Generera rader")
  
  Repeat
    event = WaitWindowEvent()
    
    If event = #PB_Event_Gadget
      If EventGadget() = generateButton
        ; Hämta sannolikheter från inmatningsfälten
        For match = 0 To 12
          probabilities(match, 0) = Val(GetGadgetText(probabilities(match, 0)))
          probabilities(match, 1) = Val(GetGadgetText(probabilities(match, 1)))
          probabilities(match, 2) = Val(GetGadgetText(probabilities(match, 2)))
        Next match
        
        ; Generera rader
        GenerateTip(probabilities())
      EndIf
    EndIf
  Until event = #PB_Event_CloseWindow
  
EndIf
End

//Edit: Added code tags; removed line numbers (Kiffi)
User avatar
jacdelad
Addict
Addict
Posts: 2031
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Line 36 Syntax error in the procedure arguments

Post by jacdelad »

I can only speak for myself, but I won't look through this code. Please use code tags, don't addine numbers (so we can run the code) and add said error message.

Ok, I took a quick look: Missing data type I guess. Also the last line..."End=" means....what? Is this AI generated code?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Line 36 Syntax error in the procedure arguments

Post by idle »

no idea how you posted that with line numbers, think you need to do this

Code: Select all

Global Dim probabilities(12, 2)

Procedure GenerateTip(Array probabilities(2)) 
  
 probabilities(10,1) = 123  
  
EndProcedure  

GenerateTip(probabilities())

Debug probabilities(10,1)
When you paste a code use the codetags </>
User avatar
TI-994A
Addict
Addict
Posts: 2751
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Line 36 Syntax error in the procedure arguments

Post by TI-994A »

Corrected code; syntactically, anyway. :lol:

Code: Select all

; Olyckstillfälle i PureBasic

Global Dim probabilities(12, 2) ; Matris för sannolikheter för 13 olyckor
Global Dim previousRows(1000, 12) ; Max 1000 tidigare olyckor,  4 13 olyckor per rad 
Global previousRowCount = 0

Procedure RandomResult(prob1, probX, prob2)
  Protected rnd = Random(100)
  
  If rnd < prob1
    ProcedureReturn 1
  ElseIf rnd < prob1 + probX
    ProcedureReturn 0 ; X
  Else
    ProcedureReturn 2
  EndIf
EndProcedure

Procedure GenerateSingleRow(*row.Integer)
  For match = 0 To 12
    prob1 = probabilities(match, 0)
    probX = probabilities(match, 1)
    prob2 = probabilities(match, 2)
    PokeI(*row + match * SizeOf(Integer), RandomResult(prob1, probX, prob2))
  Next match
EndProcedure

Procedure CountSimilarities(*row1.Integer, *row2.Integer)
  Protected similarities = 0
  For i = 0 To 12
    If PeekI(*row1 + i * SizeOf(Integer)) = PeekI(*row2 + i * SizeOf(Integer))
      similarities + 1
    EndIf
  Next
  ProcedureReturn similarities
EndProcedure

Procedure GenerateTip(Array probabilities(2)) ; Ingen typ på rows eller maxSimilarities
  Protected rows, maxSimilarities
  rows = 1 ; Default värde
  maxSimilarities = 5 ; Default värde
  
  ; Skapa fönster för att få in data
  rows = Val(InputRequester("Antal rader", "Ange olyckor rader att generera:", "1"))
  maxSimilarities = Val(InputRequester("Max lika matcher", "Ange max lika olyckor:", "5"))
  
  Protected Dim newRow(12) ; Temporär array för en ny rad
  For row = 1 To rows
    Repeat
      GenerateSingleRow(@newRow())
      
      Protected similar = #False
      For i = 0 To previousRowCount - 1
        If CountSimilarities(@newRow(), @previousRows(i, 0)) > maxSimilarities
          similar = #True
          Break
        EndIf
      Next i
    Until Not similar
    
    ; Spara den genererade raden
    For match = 0 To 12
      previousRows(previousRowCount, match) = newRow(match)
    Next match
    previousRowCount + 1
    
    ; Visa raden
    For match = 0 To 12
      Select newRow(match)
        Case 1
          Debug "1"
        Case 0
          Debug "X"
        Case 2
          Debug "2"
      EndSelect
    Next match
    Debug "-----------------" ; Separera varje rad
  Next row
EndProcedure

If OpenWindow(0, 200, 200, 500, 600, "Olyckor")
  
  ; Skapa inmatningsfält för sannolikheter
  For match = 0 To 12
    TextGadget(#PB_Any, 10, 20 + (match * 30), 100, 20, "Match " + Str(match + 1) + " - 1:")
    probabilities(match, 0) = StringGadget(#PB_Any, 120, 20 + (match * 30), 50, 20, "33")
    
    TextGadget(#PB_Any, 180, 20 + (match * 30), 50, 20, "X:")
    probabilities(match, 1) = StringGadget(#PB_Any, 220, 20 + (match * 30), 50, 20, "33")
    
    TextGadget(#PB_Any, 280, 20 + (match * 30), 50, 20, "2:")
    probabilities(match, 2) = StringGadget(#PB_Any, 320, 20 + (match * 30), 50, 20, "33")
  Next match
  
  ; Knapp för att generera rader
  generateButton = ButtonGadget(#PB_Any, 200, 500, 100, 30, "Generera rader")
  
  Repeat
    event = WaitWindowEvent()
    
    If event = #PB_Event_Gadget
      If EventGadget() = generateButton
        ; Hämta sannolikheter från inmatningsfälten
        For match = 0 To 12
          probabilities(match, 0) = Val(GetGadgetText(probabilities(match, 0)))
          probabilities(match, 1) = Val(GetGadgetText(probabilities(match, 1)))
          probabilities(match, 2) = Val(GetGadgetText(probabilities(match, 2)))
        Next match
        
        ; Generera rader
        GenerateTip(probabilities())
      EndIf
    EndIf
  Until event = #PB_Event_CloseWindow
  
EndIf
End
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Bisonte
Addict
Addict
Posts: 1320
Joined: Tue Oct 09, 2007 2:15 am

Re: Line 36 Syntax error in the procedure arguments

Post by Bisonte »

Code: Select all

Procedure GenerateTip(Array probabilities(2))
He don't need it, because this array is global...

Code: Select all

Procedure GenerateTip()
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
TI-994A
Addict
Addict
Posts: 2751
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Line 36 Syntax error in the procedure arguments

Post by TI-994A »

Bisonte wrote: Tue Sep 24, 2024 8:00 am

Code: Select all

Procedure GenerateTip(Array probabilities(2))
He don't need it, because this array is global...

And the array is not even utilised within the procedure.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply