' Empty thinBasic CONSOLE file template
Uses "Console"
Type t_x
A As Long
B As Long
C As Long
D As Long
End Type
Dim foo() As t_x
ReDim foo(1)
Dim nFoos As Long
While TRUE
PrintL "Press key"
WaitKey
PrintL "foo(" + TStr$(New_Foo()) +") created"
Wend
Function New_Foo() As Long
nFoos += 1
ReDim Preserve foo(nFoos)
Randomize
With foo(nFoos)
.A = Rnd(1000)
PrintL ".A =" + Str$(.A)
.B = Rnd(1000)
PrintL ".B =" + Str$(.B)
.C = .A - .B
PrintL ".C =" + Str$(.C)
.D = IIf(.C > 0, .A, .B)
PrintL ".D =" + Str$(.D)
End With
Return nFoos
End Function
Run a few times, i.e. press key until it happens...
Edit: seems to me the IIF breaks WITH - the End With gets ignored thereafter
Bookmarks