Structure definition problem

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
om3bc
Posts: 7
Joined: 27 Mar 2019 09:01

Structure definition problem

#1 Post by om3bc » 11 May 2022 07:58

I try to declare structure in MIKROBASIB Pro for PIC32 v 4.0.0, but I get error message. Why?

Best regards Joe
Attachments
Screen Shot 05-11-22 at 06.47 AM.PNG
Screen Shot 05-11-22 at 06.47 AM.PNG (137.07 KiB) Viewed 1197 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Structure definition problem

#2 Post by filip » 19 May 2022 09:07

Hi,

Please try to put the structure member initialization in a sub function/procedure.

Regards,
Filip.

om3bc
Posts: 7
Joined: 27 Mar 2019 09:01

Re: Structure definition problem

#3 Post by om3bc » 20 May 2022 08:10

sub procedure def_struc()
structure Dot
dim x as float
dim y as float
end structure

structure Circle0
dim radius as float
dim center as Dot
end structure

dim circle1, circle2 as Circle0
circle1.radius = 3.7
circle1.center.x = 0
circle1.center.y = 0
end sub

Is working, but how I can use variables as global?

Joe

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Structure definition problem

#4 Post by filip » 27 May 2022 09:14

Hi,

Here is a simple example :

Code: Select all

program test

structure Dot  
  dim x_coord as float
  dim y_coord as float
end structure

dim m, n as Dot

main:
  m.x_coord = 0
  m.y_coord = 0
end.
Regards,
Filip.

Post Reply

Return to “mikroBasic PRO for PIC32 General”