Oxygen Basic
Programming => Bugs & Feature Requests => Topic started by: Peter on October 05, 2013, 05:29:24 AM
-
Deleted
-
Hi Peter,
When dimensioning an array, the index specified is the highest element, using the indexbase.
This is a legacy of PB & also FB (I have not checked)
I could change it so that it specifies the number of elements in the array instead. I think that might be preferable. What do you think?
-
To clarify: I was referring to the dim index rather than spanof()
Thus:
Indexbase 0
sys a[100]
currently a contains 101 elements
I am proposing that it should be 100 elements regardless of indexbase.
-
eheh ;D
I discussed this situation so many times with other programmers especially C programmers.
You dimension whatever to X and you get X+1 elements.
If you want X elements you need to dimension it X-1
In thinBasic I decided to FIX base to 1. No other options.
Yes, I was quite drastic.
-
I typically like to use the zero element as a status like element in code I write. The real data starts at one.
-
This isn't possible due to 1000 programs which base on IndexBase 0.
Eros is too fast with his decisions!
Yeah...old Eros 'hate' zero base option...and i am not sure why because most of standard windows
controls are zero based
edit - first line 0
richedit - 0
listbox - 0
combobox 0
tabcontrol 0
uff i have some freakin problems with tab control and not to use 0 based first tab
etc...etc....
Of course that this thing can be avoided....
and when we looking from human-logical side it is far logical to
start from 1-100 than from 0-99 ...i agree with that ;D
-
I would like to stay with traditional BASIC syntax as a core and extend the feature set from there. Making arrays not start at zero breaks too much code. IMHO
Trying to get rid of GOTO/GOSUB is another battle traditional BASIC fights.
-
Yes,...Charles why is default indexbase 1 ?
i just ask....
-
Indexbase 1: This is the easiest to understand, and most convenient for simple programs. It is also compatible with character indexing in strings.
The pros who work with the sdk or pixel arrays will naturally prefer IndexBase 0.
You can change the indexbase at any point in the program, or alter it locally in a function. It only affects the frame of reference.
PS: goto will always be supported since it is essential for low level programming.
-
I like the option of 1 or 0 as in OxygenBasic, only because as many stated lots of other languages use 0.
It is nice to have the flexibility.
If the earlier programming languages were from a perfect world, I think using 1 would have been better as Eros chose
in thinBasic.
But for the size, I think saying array[10] would be 10 elements total and not 11.
indexbase 0 that would be 0-9
indexbase 1 that would be 1-10
-
goto will always be supported since it is essential for low level programming.
yes GOTO is fine.... ;)