0

Some improvements to Arrays

Antonio Garcia 3 years ago in IQANdesign updated 3 years ago 0

Hello,


I know there's a wide list of possible array improvements out there, but I would like to post my main concerns. (I think none of them are already supported).


Array easy static initialization 

In case of having to work with large arrays, plain initialization line by line is tedious (I use excel or some external editor to write the lines, and then copy&paste them to IQAN). 


array_name[0] := 0xA0

array_name[1] := 0xA5

...

array_name[1200] := 0x00


Apart, when there's such big amount of lines, it really slows down the IDE when oppening and scrolling this channel.


I don't really know if this kind of initialization, with constant numbers, is somehow optimized, or it is executed every cycle. I haven't really tested %cycle, but I use to do something like:


static init:=TRUE

IF( init ) THEN

array_name[0] := 0xA0

...

array_name[1200] := 0x00

init := FALSE

ENDIF


Just in case.


So, a major improvement would be to have an easier method of static initialization. 

Perhaps, a C-like way: array_name := [0xA0, ... , 0x00]. 

Or, from an csv o txt, just like LUT.


A minor and faster update, would be adding the "static" keyword to arrays, in order to perform a real one-time initialization, while maintaining the classic array filling method.

So, the following piece of code at the very beginning:


static array_name[0] := 0xA0

...

static array_name[1200] := 0x00


Would mean it is an initialization, and not a cycle by cycle assignment.


Array Function Selector

Not meant to multiply array size (array values should be shared and preserved between states, if not overwriten), but to perform different operations or asigments depending on the state variable, just like in any other channel. At the moment I must use uglier methods, whereas a function selector would make it much more elegant.



Loops in QCode. 

At least, just inside array's QCode. This has already been asked before in other posts. Really simple algorithims became overkill in IQAN due to lack of Loops.



Thanks!