Page 1 of 1
Just a simple Syntax error
Posted: Fri Jan 19, 2024 3:26 am
by jphoarau
Hello everybody,
I'm a little ashamed to ask this question, but I'm stuck on a syntax error. It's on line 17 and I can't figure out my mistake. Can anyone unblock me?
Code: Select all
Structure Part
part_name.s
sound.b
hours.b
minuts.b
seconds.b
EndStructure
Structure Session
session_name.s
Array part_Array.Part(10)
EndStructure
Global Dim part_Array.Part(10)
Global session.Session
Procedure FillPartArray(part_default.Part, snd_nbr.b, n); Here is the syntax error
Define i = n
For x = 0 To (i - 1)
With part_default
\part_name = "New Part " + Str(i)
\sound = snd_nbr
\hours = 0
\minuts = 5
\seconds =0
part_Array(x) = part_default
EndWith
Next x
EndProcedure
Re: Just a simple Syntax error
Posted: Fri Jan 19, 2024 4:39 am
by BarJo
Hi jphoarau,
I am still a beginner with SpiderBasic, but I would have coded it like this:
Code: Select all
Structure Part
part_name.s
sound.b
hours.b
minuts.b
seconds.b
EndStructure
Structure Session
session_name.s
Array part_Array.Part(10)
EndStructure
Global Dim part_Array.Part(10)
Global session.Session
Procedure FillPartArray(List part_default.Part(), snd_nbr.b, n); Here is the syntax error
Define i = n
For x = 0 To (i - 1)
With part_default()
\part_name = "New Part " + Str(i)
\sound = snd_nbr
\hours = 0
\minuts = 5
\seconds =0
part_Array(x) = part_default()
EndWith
Next x
EndProcedure
Re: Just a simple Syntax error
Posted: Fri Jan 19, 2024 7:25 am
by jphoarau
BarJo wrote: Fri Jan 19, 2024 4:39 am
Hi jphoarau,
I am still a beginner with SpiderBasic, but I would have coded it like this:
Thanks for your answer. It makes me understand my mistake. A Structure can't be passed as Procedure parameter. It must be passed by pointer. I have found this with your help:
Code: Select all
Structure Part
part_name.s
sound.b
hours.b
minuts.b
seconds.b
EndStructure
Structure Session
session_name.s
Array part_Array.Part(10)
EndStructure
Global Dim part_Array.Part(10)
Global session.Session
Global part_default.Part
Procedure FillPartArray(*part_temp.Part, snd_nbr.b, n); Here is the syntax error
Define i = n
For x = 0 To (i - 1)
With *part_temp
\part_name = "New Part " + Str(i)
\sound = snd_nbr
\hours = 0
\minuts = 5
\seconds =0
EndWith
part_Array(x) = part_default
Next x
EndProcedure
FillPartArray(@part_default, 0, 3)
Many thanks.
Re: Just a simple Syntax error
Posted: Sun Jan 21, 2024 6:44 am
by BarJo
jphoarau wrote: Fri Jan 19, 2024 7:25 am
BarJo wrote: Fri Jan 19, 2024 4:39 am
Hi jphoarau,
I am still a beginner with SpiderBasic, but I would have coded it like this:
Thanks for your answer. It makes me understand my mistake. A Structure can't be passed as Procedure parameter. It must be passed by pointer. I have found this with your help:
Code: Select all
Structure Part
part_name.s
sound.b
hours.b
minuts.b
seconds.b
EndStructure
Structure Session
session_name.s
Array part_Array.Part(10)
EndStructure
Global Dim part_Array.Part(10)
Global session.Session
Global part_default.Part
Procedure FillPartArray(*part_temp.Part, snd_nbr.b, n); Here is the syntax error
Define i = n
For x = 0 To (i - 1)
With *part_temp
\part_name = "New Part " + Str(i)
\sound = snd_nbr
\hours = 0
\minuts = 5
\seconds =0
EndWith
part_Array(x) = part_default
Next x
EndProcedure
FillPartArray(@part_default, 0, 3)
Many thanks.
Yes, you're right, I answered too quickly.
Re: Just a simple Syntax error
Posted: Sun Jan 21, 2024 3:07 pm
by jphoarau
BarJo wrote: Sun Jan 21, 2024 6:44 am
Yes, you're right, I answered too quickly.
No, you helped me find the solution. Thank you.