#define does not work as array size

6 years 4 months ago - 6 years 4 months ago #29532925 by maple
Neither variable nor macro work as array size in dim.
I understand why variable might not work, but pre-processor directive is pretty much constant and supposed to be handled by simple substitution in code.
There is no reason for it not to work.

Also, declaring array of length 1 produces an error "Array variables length should be greater than 1".
Why is that, exactly? What is wrong with array of length 1?

I am writing many universal procedures for use in multiple projects. If some project does not need more than one value it would require code change, with potential to introduce new bugs. For example, I have complex filtering code that needs intermediate storage. This code is called as many times as there are analog inputs in use, with input index set up in advance. Ideally, I would like to be able to write something like this:
#define FILTERS 1
dim filter_buffer[FILTERS] as integer
. . .
for filter_index = 0 andwhile filter_index < FILTERS
    gosub Filter
. . .
oldvalue = filter_buffer[filter_index]
. . .

Please Log in or Create an account to join the conversation.

Time to create page: 0.048 seconds