You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
.. was introduced and referred to in the doc as "an array:"
These should not be called "arrays" because none of the array statements ( UBOUND(), SORT, SCAN, REDIM, etc) work on them. They should be called "tables" or there is going to be a lot of confusion moving into the future.
Last edited by Michael Mattias; 17 Sep 2020, 07:06 PM.
Reason: Correct typo "SACN" to correct spelling "SCAN"
I do get -1, but I have populated the array.
As long as I know ubound works for structured arrays, I'll check my code.
thank you
As Dale says, "not possible"
Do you have #DIM ALL ? If not, it could be a spelling discrepancy with the array name - regardless, you should always use it.
Do you have #DEBUG DISPLAY ON / #DEBUG ERROR ON to trap array out of bounds errors? - it pays to have both of these on while developing (comment them out for final tested code with appropriate error trapping)
Do you have the same array name declared both as global and also in a sub/function?
It *kind* of works... but if not, how can I get the ubound of a typed array?
As I understand the documentation:
Code:
function PBmain() as long
type MyDataType
FirstName as Asciiz * 20
LastName as Asciiz * 50
KnownAliases( 1 to 10) as AsciiZ * 20
end type
local MyData() as MyDataType
dim MyData(1 to 10)
'This is legal
? ubound(MyData)
'This is not
? UBOUND(MyData.KnownAliases)
end function
You have an array of a user defined type, not an array in a user defined type.
(added - In Help for TYPE/END TYPE, see subscripts section for arrays in a UDT.)
UBOUND should work. (except that in your DIM statement you do not specify the number of elements in the array.
example:
dim csaTable(9) as csaType
or
dim csaTable(1 to 10) as csaType
(both dim with 10 elements)
Type csaType
cLine As String * 75
cSampleID As String * 75
cAggl As String * 10
cMot As String * 10
cVol As String * 10
cConc As String * 10
cTSD As String * 10
cTar As String * 10
cTech As String * 75
End Type
then I dimension an array
Code:
dim csaTable() as csaType
I have several arrays like this in my program.
I was using UBOUND(csaTable)
and it was working, then suddenly on one array it didn't work.
I looked at PB help and I see
UBOUND cannot be used on arrays within User-Defined Types.
It *kind* of works... but if not, how can I get the ubound of a typed array?
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: