Initializing arrays
CarlosFandango
Posts: 67
I've been looking through the manual and the forum, but I can't seem to find an answer to this simple question.
Is it possible to initialise all array elements to a given value in one go by using a range specification of some sort, or do they all have to be initialized individually? Obviously a loop for large arrays makes sense but I was hoping for something like my_array[noparse][[/noparse]0..3] := 0 rather than the lengthier alternatives.
-CF
Is it possible to initialise all array elements to a given value in one go by using a range specification of some sort, or do they all have to be initialized individually? Obviously a loop for large arrays makes sense but I was hoping for something like my_array[noparse][[/noparse]0..3] := 0 rather than the lengthier alternatives.
-CF
Comments
In your example, if my_array was declared as long, you could write: LONGFILL(@my_array,0,4)
You might also consider using DAT for your array:
DAT
my_array long 0
I vaguely remember reading about a syntax that allows you to specify multiple instances of data in DAT like so:
but I could be mistaken.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."
- Bjarne Stroustrup