I am not saying that it is difficult - but in a loop to place the words in an array. I would need to add 1 to the array index.
So then, a human asked to remember the position of the word "fox" could get the right answer by typing "4".
Either that or I could store them in the array starting at position 0 but would have to subtract 1 from the human's input.
This is a simple example - it can get more complicated with rectangular tables and is probably why Excel uses base 1 for its Row, Column addressing.
OPTION BASE 1
- cicciocb
- Site Admin
- Posts: 2060
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 439 times
- Been thanked: 1360 times
- Contact:
Re: OPTION BASE 1
Still the same question : why you must add or subtract 1 ?[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Jul 12, 2023 5:52 pm I am not saying that it is difficult - but in a loop to place the words in an array. I would need to add 1 to the array index.
So then, a human asked to remember the position of the word "fox" could get the right answer by typing "4".
Either that or I could store them in the array starting at position 0 but would have to subtract 1 from the human's input.
This is a simple example - it can get more complicated with rectangular tables and is probably why Excel uses base 1 for its Row, Column addressing.
You can simply ignore that the position 0 exists and that's all
example
Code: [Local Link Removed for Guests]
A$="The quick brown fox jumps over the lazy dog"
dim arr$(9) ' the message contains 9 words - the array contains the elements from 0 to 9
for z = 1 to 9
arr$(z) = words$(a$, z)
next z
for z = 1 to 9
print arr$(z)
next z
-
- Posts: 143
- Joined: Mon Feb 08, 2021 10:10 pm
- Location: Scotland
- Has thanked: 47 times
- Been thanked: 51 times
Re: OPTION BASE 1
Yes - I see that you can do it that way for the simple example. I would have to rake back through years of VB programs to find the ones that gave me problems.
For now - you win.
But "fox"is still the fifth element in your array...
For now - you win.
But "fox"is still the fifth element in your array...
- cicciocb
- Site Admin
- Posts: 2060
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 439 times
- Been thanked: 1360 times
- Contact:
Re: OPTION BASE 1
Doesn't matter, I can simply implement the option base 1 ignoring the first element; 'fox' will always the fifth element but the first will be simply inaccessible.[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Jul 12, 2023 6:08 pm Yes - I see that you can do it that way for the simple example. I would have to rake back through years of VB programs to find the ones that gave me problems.
For now - you win.
But "fox"is still the fifth element in your array...
What I want say is that is not the option base 1 the point but is how you write into the arrays
It is not question to lose or win but I cannot find a valid reason that justify
- Fernando Perez
- Posts: 378
- Joined: Mon Feb 15, 2021 10:09 pm
- Location: Santander (Spain)
- Has thanked: 195 times
- Been thanked: 267 times
Re: OPTION BASE 1
Mon dieu, how bored we are..
Do we have the family visiting, with their children, for vacations?
I'm sorry I brought this thread up, I appreciate Bugs' support and I'll end triumphantly by saying: "Eppur si muove"
Do we have the family visiting, with their children, for vacations?
I'm sorry I brought this thread up, I appreciate Bugs' support and I'll end triumphantly by saying: "Eppur si muove"
- cicciocb
- Site Admin
- Posts: 2060
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 439 times
- Been thanked: 1360 times
- Contact: