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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

change array index value

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

0 Kudos
Message 1 of 11
(3,863 Views)

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.

0 Kudos
Message 2 of 11
(3,862 Views)

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

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 3 of 11
(3,839 Views)

Your question caused me to experience a flashback to when I used Visual Basic.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 4 of 11
(3,828 Views)

 

 

Yes....the range of the array index can be 0 to 10 or 1 to 10...using DIM statement

0 Kudos
Message 5 of 11
(3,821 Views)

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.

0 Kudos
Message 6 of 11
(3,813 Views)

@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

0 Kudos
Message 7 of 11
(3,805 Views)

In PL/M, an array can have any number as it's index base.

0 Kudos
Message 8 of 11
(3,794 Views)

So, why not with Labview? I guess it's never been considered before

0 Kudos
Message 9 of 11
(3,758 Views)

Considered and discarded as an idea that has no merit.Smiley Wink

 

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?

Message 10 of 11
(3,755 Views)