Save the trouble. When you fill your array, use a for loop
for m%=lbound(array%) to ubound(array%)
array%(m%)=RND(0) 'Example
next
------------------
Amos
Announcement
Collapse
No announcement yet.
Problem with ARRAY SORT
Collapse
X
-
Guest replied
-
Hi
Thanks to Mike and Lance. I was aware that arrays can begin with 0.
However, the manual doesn't show that. I was following the manual.
I have update the manual to refect this.
Thanks again.
Fred
------------------
Leave a comment:
-
I think Mike hit the nail on the head here... there are absolutely no known or reported issues with ARRAY SORT, except those that are found to be program(mer) errors.
If you DIM an array like so:
DIM A%(10)
you actually get 11 subscripts {A%(0) to A%(10)}, so an array sort like:
ARRAY SORT A%() FOR 10
will omit the 11th subscript in the array {A%(10)} from the sort.
Another common mistake is to use:
ARRAY SORT A%(1) FOR 10
which leaves the 1st subscript out of the sort {A%(0)}
Failing this, please post an example that shows your problem... thanks!
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment:
-
By chance have you ommitted observing that arrays can start
with the (0)'th element and left to it's own devices, PowerBASIC
expects you to be using it that way?
I think you can move it up to start at the (1)'st element by
setting OPTION BASE to 1, but it takes your effort to get it
moved there, one way or another...
Just thinking out loud.
------------------
Mike Luther
[email protected]
Leave a comment:
-
Problem with ARRAY SORT
Hi
It appears that I am having problem with ARRAY SORT. I generate a
list of random numbers then have the compute sort them using ARRAY
SORT. I then wish to use the first four lowest numbers. However, I
have noticed that generally one of the four wanted numbers is the
last one in the unsorted list of numbers BUT when I come to check
the sorted list it is not in the list of four least numbers. An
example of a recent list is a follows:
beginning of unsorted list
222
461
215
552
508
344
end of unsorted list
beginning output of sorted list
215
222 (344 should come after 222)
461
508
end of sorted list
I have made a number of runs and with the same results the last number
in the unsorted list isn't included in the sorted list.
Any help?
Fred Katzel
------------------
Tags: None
Leave a comment: