Ubound failed to get maximum index from nested type.

General FreeBASIC programming questions.
Tiranas
Posts: 4
Joined: Oct 12, 2018 19:55
Location: Russian

Ubound failed to get maximum index from nested type.

Postby Tiranas » Oct 12, 2018 20:06

Ubound failed to get maximum index from nested type.

Code: Select all

Type tValE
  sNameV As String
  sValue As String
End Type

Type tEnum
  sName As String
  sType As String
  sVal(Any) As tValE
End Type

Dim Shared en(Any) As tEnum
Dim as Integer e2 = -1, n2
Dim as String s2, s3

e2 += 1: ReDim Preserve en(e2)
220: n2 = UBound(en(e2).sVal) + 1: ReDim Preserve en(e2).sVal(n2)
221: en(e2).sVal(n2).sNameV = s2
222: en(e2).sVal(n2).sValue = s3



Build error(s)
C:\FreeBasic\Compilier\fbc -s console "FbTemp.bas"
FbTemp.bas(220) error 3: Expected End-of-Line, found '.' in 'n2 = UBound(en(e2).sVal) + 1: ReDim Preserve en(e2).sVal(n2)'

Build error(s)


Tell me, please, what is the problem.
fxm
Posts: 10061
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Ubound failed to get maximum index from nested type.

Postby fxm » Oct 12, 2018 20:30

Welcome to the forum.

The problem is not on UBound, but on ReDim:

Code: Select all

ReDim Preserve (en(e2).sVal)(n2)
See REDIM, paragraph NOTES, last point.
Tiranas
Posts: 4
Joined: Oct 12, 2018 19:55
Location: Russian

Re: Ubound failed to get maximum index from nested type.

Postby Tiranas » Oct 12, 2018 23:27

Thank you so much!!! I was tortured...

Return to “General”

Who is online

Users browsing this forum: Google [Bot] and 15 guests