Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:19 18 Mar 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite BASIC STRUCTs

Author Message
Mark
Regular Member

Joined: 26/11/2022
Location: United States
Posts: 87
Posted: 11:02pm 17 Mar 2026
Copy link to clipboard 
Print this post

I have been programming in PicoMite BASIC 6.02 and really enjoy it. I've been experimenting with the new STRUCT's and find them powerful.  I find that arrays of STRUCTs inside a STRUCT don't behave as I am expecting;


TYPE KeyLink
 Link AS INTEGER
 Key AS STRING LENGTH 15
END TYPE

TYPE Tree
 TreeD AS INTEGER
 KeyLinks(20) AS KeyLink
END TYPE

DIM T as Tree, KL AS KeyLink
DIM L as INTEGER, K as STRING


This works, but there are couple things that don't work the way I expect based on my experience with other languages.  When declaring an array outside of a STRUCT, you can define a CONST and use that to define the array size, but inside a STRUCT (KeyLInks), it seems like. you have to use a number.

It seems like you can't use a subscript to access a KeyLinks member:


KL = T.KeyLinks(10)


This always seems to assign the value off T.KeyLinks(0) regardless of the subscript, but code like


L = T.KeyLInks(10).Link
K = T.KeyLinks(10).Key


Seems to work as expected.
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 571
Posted: 03:23am 18 Mar 2026
Copy link to clipboard 
Print this post

  Mark said  I have been programming in PicoMite BASIC 6.02 and really enjoy it. I've been experimenting with the new STRUCT's and find them powerful.  I find that arrays of STRUCTs inside a STRUCT don't behave as I am expecting;


TYPE KeyLink
 Link AS INTEGER
 Key AS STRING LENGTH 15
END TYPE

TYPE Tree
 TreeD AS INTEGER
 KeyLinks(20) AS KeyLink
END TYPE

DIM T as Tree, KL AS KeyLink
DIM L as INTEGER, K as STRING


This works, but there are couple things that don't work the way I expect based on my experience with other languages.  When declaring an array outside of a STRUCT, you can define a CONST and use that to define the array size, but inside a STRUCT (KeyLInks), it seems like. you have to use a number.

It seems like you can't use a subscript to access a KeyLinks member:


KL = T.KeyLinks(10)


This always seems to assign the value off T.KeyLinks(0) regardless of the subscript, but code like


L = T.KeyLInks(10).Link
K = T.KeyLinks(10).Key


Seems to work as expected.


I wouldn't expect T.KeyLinks(10) to work. Each KeyLinks element is made up of a Link and a Key. You have to specify which one you want when referencing KeyLinks
 
Mark
Regular Member

Joined: 26/11/2022
Location: United States
Posts: 87
Posted: 04:03am 18 Mar 2026
Copy link to clipboard 
Print this post

Thanks for responding.

What I want to do is copy both the Key and Link parts of the KeyLink STRUCT at element 10 of the KeyLinks() array to the Key and Link parts of a scalar (non array) KeyLink variable. Why don't you expect it to work? (It doesn't).

Mark
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026