From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-20-2010 07:59 PM
Good Morning
Is it possible to change an array index value to begin the count from 1 rather than 0. Within the program I am writing at the moment, I would like it as a permanent feature.
I have made some attempts with property nodes, but without success.
Why do I want to do this you may ask.
So that a lay person can change the row in the array using plain old counting style...1,2,3,4 etc.
Thanks in advance
Ray
07-20-2010 08:10 PM
No, the underlying primitives for array indexing are always zero-indexed, you cannot change these primitives to use another indexing system. Keep in mind, you can always use the Increment and Decrement primitives to act as transfer functions between your User Interface (UI) and underlying implementation.
07-21-2010 02:46 AM
You can't.
You shouldn't:
here's a broad discussion on Stackoverflow, which points to this paper that has some nice insights.
A lot of calculations are based on the zero-based indexing.
You could easily replace the current index by your own numbering.
Ton
07-21-2010 05:19 AM
07-21-2010 05:54 AM
Yes....the range of the array index can be 0 to 10 or 1 to 10...using DIM statement
07-21-2010 07:05 AM
The index that the operator uses can start at 1 and you can do "minus 1" to start the index at 0 within your code.
07-21-2010 07:54 AM
@jcarmody wrote:
Your question caused me to experience a flashback to when I used Visual Basic.
I believe MATLAB is also 1 based. Not sure if there is an option to set it to 0 based or not. At least VB has that
07-21-2010 09:29 AM
In PL/M, an array can have any number as it's index base.
07-21-2010 04:45 PM
So, why not with Labview? I guess it's never been considered before
07-21-2010 04:48 PM
Considered and discarded as an idea that has no merit.
Since you can easily create a front panel control that starts at whatever number you want and you can easily add/subtract from that to index the array, what else do you need?