FreeBASIC  0.91.0
array_ubound.c
Go to the documentation of this file.
1 /* ubound function */
2 
3 #include "fb.h"
4 
5 FBCALL ssize_t fb_ArrayUBound( FBARRAY *array, ssize_t dimension )
6 {
7  /* given dimension is 1-based */
8  dimension -= 1;
9 
10  /* out-of-bound dimension? */
11  if( (dimension < 0) || (dimension >= array->dimensions) ) {
12  /* ubound( a, 0 ) returns the array's dimension count.
13  Any other out-of-bound dimension value returns -1.
14  (see also fb_ArrayLBound()) */
15  return dimension == -1 ? array->dimensions : -1;
16  }
17 
18  return array->dimTB[dimension].ubound;
19 }