Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:46 07 Jul 2025 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 : arrays of strings

Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2431
Posted: 02:40am 28 Feb 2017
Copy link to clipboard 
Print this post

page 55 of the micromite manual gives several examples of using the DIM statement, including:

DIM name AS STRING
DIM strn$(200) LENGTH 20

these two examples suggest to me that the following should work:

DIM info(200) AS STRING LENGTH 16

it does not:

> DIM info(200) AS STRING LENGTH 16
Error: Not enough memory
>

the specified length is ignored. whereas:

Dim STRING info(200) LENGTH 16

behaves as expected:

> Dim STRING info(200) LENGTH 16
> memory
Flash:
1K ( 0%) Program (47 lines)
59K (100%) Free

RAM:
4K ( 7%) 1 Variable
0K ( 0%) General
46K (93%) Free
>

is this (DIM info(200) AS STRING LENGTH 16) the sign of a bug?


cheers,
rob :-)Edited by robert.rozee 2017-03-01
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2431
Posted: 03:01am 28 Feb 2017
Copy link to clipboard 
Print this post

as an aside to this, what is the material difference between a$ and b$ below:

> dim string a$="line one"
> dim b$="line two"
> ? a$
line one
> ? b$
line two
> ? a
line one
> ? b
Error: B already declared
>

ie, if we were to examine the variable tables in memory, what would be different between the two variables to cause the differing behaviour? is there a need for them to be different or to behave differently?


cheers,
rob :-)
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 03:26am 28 Feb 2017
Copy link to clipboard 
Print this post

I have always have problem remembering the syntax for fixed length string arrays.
The manual does not make it easier.
It is the only statement in the manual that i somehow can not get into my head. :)
The rest of the manual is easy to follow, but that DIM statement for arrays .... i just copy and paste a working snippet, but that does not help to remember also.



Microblocks. Build with logic.
 
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 2025