Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

wish for BASCOM future versions => user defined stuctures
Goto page 1, 2  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Sarek

Bascom Member



Joined: 15 Oct 2009
Posts: 72

germany.gif
PostPosted: Fri Oct 09, 2015 8:51 am    Post subject: wish for BASCOM future versions => user defined stuctures Reply with quote

here an example for my wish "user defined stuctures"

Code:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' User defined variable structures
' with optional preset values
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Define Pos_xy as Struct
        X as Word : X = 50
        Y as Word : Y = 10
End_Struct

Define Dimension_wh as Struct
        width  as Word : width  = 20
        height as Word : height = 100
End_Struct
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' User defined variable structure
' with substructures
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Define Box_var as Struct
        Pos        as Pos_xy
        Dimension  as Dimension_wh
        Line_width as Byte : Line_width = 16
End_Struct
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' DIM a variable Structures
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim My_Box_1 as Box_var
Dim My_Box_2 as Box_var
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' example Accessing variable Structures
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My_Box_1.Pos.X = 20
My_Box_1.Pos.Y = 100
...
...
My_Box_2.Pos.X = 200
My_Box_2.Pos.Y = 180
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Sub with variable Structures
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub Draw_Box (Box as Box_var)

If Box.Pos.X > 150 Then ...  
...
...
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Call Subs
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Call Draw_Box (My_Box_1)
Call Draw_Box (My_Box_2)
...
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 


(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 )
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Mon Oct 12, 2015 2:51 am    Post subject: Reply with quote

If you can confine your structures to contain only variables of one data type ( words ), you could use an array. By naming the element indexes as constants, you can achieve almost exactly the same result.

But yes, now that the bigger AVRs have plenty of SRAM memory, it could be useful to implement the Basic TYPE construction. One issue still is that its not obvious to the programmer how much memory is being used, and its very easy to create structures which use far more memory than some AVRs have. At least with arrays, a glance at the relevant DIM statement shows how much memory is allocated.

Not sure about nested structures like you want, that is another level of complexity.


Mark ?

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5916
Location: Holland

blank.gif
PostPosted: Wed Oct 14, 2015 10:30 pm    Post subject: Reply with quote

when you type :

Type Test
Aa As Byte
Bb As Word
End Type

and look at the code explorer you know this wish is already on the todo list. when it is actually released for the compiler i can not tell. a matter of priorities.

_________________
Mark
Back to top
View user's profile Visit poster's website
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Thu Oct 15, 2015 12:17 am    Post subject: Reply with quote

As usual Mark, you are way ahead of us mere mortals !
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
Sarek

Bascom Member



Joined: 15 Oct 2009
Posts: 72

germany.gif
PostPosted: Thu Oct 15, 2015 12:24 pm    Post subject: Reply with quote

albertsm wrote:
when you type :

Type Test
Aa As Byte
Bb As Word
End Type

and look at the code explorer you know this wish is already on the todo list. when it is actually released for the compiler i can not tell. a matter of priorities.


Cool!

Back to top
View user's profile
techknight

Bascom Member



Joined: 21 Apr 2008
Posts: 231

usa.gif
PostPosted: Fri Oct 23, 2015 9:09 pm    Post subject: Reply with quote

I feel stupid. What is a struct? and whats its importance?

I see it ALL the time in C, and I am not a C developer so it eludes me.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Mon Oct 26, 2015 7:43 am    Post subject: Reply with quote

The equivalent basic term is a TYPE. Ie a collection of lower order variables of different sorts, but treated together into one variable name. Useful, but can be done with arrays and overlays in Bascom.
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
techknight

Bascom Member



Joined: 21 Apr 2008
Posts: 231

usa.gif
PostPosted: Mon Oct 26, 2015 1:54 pm    Post subject: Reply with quote

so TYPE is just a pointer in memory to those variable locations defined under it?
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Mon Oct 26, 2015 10:46 pm    Post subject: Reply with quote

Yes, you could look at it like that. The advantage is in the way you reference any of the components. See a full description of TYPE in Visual Basic ( or soon in Bascom ! )
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
techknight

Bascom Member



Joined: 21 Apr 2008
Posts: 231

usa.gif
PostPosted: Tue Oct 27, 2015 3:29 pm    Post subject: Reply with quote

I never knew it even existed, and ive wrote alot of stuff. But the stuff I write have all been control systems related with no games, etc.. So maybe I never needed it for anything.
Back to top
View user's profile
Sarek

Bascom Member



Joined: 15 Oct 2009
Posts: 72

germany.gif
PostPosted: Fri Jun 07, 2019 8:18 am    Post subject: Reply with quote

@Mark
any news with this feature?
Back to top
View user's profile
six1

Bascom Expert



Joined: 27 Feb 2009
Posts: 553

germany.gif
PostPosted: Fri Jun 07, 2019 7:07 pm    Post subject: Reply with quote

it's frustrating

as Mark told you: It's a matter of time and it will be there if you can see it it newer version...

you can't speed up the process by asking multible times...


clear now?


German language:
Mark macht wirklich alles Menschen mögliche und bemüht sich sehr.
Wenn er sagt, dass es kommt, dann kommt es auch.
Weil er aber an den neuen Programmieralgos hängt, was einfach wichtiger ist, dauert es eben noch.
Es ist ohnehin eine kostenlose Leistung!

Geduld junger Padawn Laughing

_________________
For technical reasons, the signature is on the back of this message.
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sat Jun 08, 2019 8:58 am    Post subject: Reply with quote

six1 wrote:
multible times...

Is this what a multiviprator does? Very Happy
Back to top
View user's profile
six1

Bascom Expert



Joined: 27 Feb 2009
Posts: 553

germany.gif
PostPosted: Mon Jun 10, 2019 7:20 pm    Post subject: Reply with quote

maybe Very Happy

english isn't my native language and sometimes i can be very creative Razz

_________________
For technical reasons, the signature is on the back of this message.
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Mon Jun 10, 2019 9:01 pm    Post subject: Reply with quote

six1 wrote:
english isn't my native language
I know, but I was not able to resist.
Quote:
sometimes i can be very creative Razz
Be creative all the time Very Happy
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum