I’m trying to create a series of text boxes in a window, using an existing text box as a template.
I have followed the code under Dynamic Controls in the User Interface Book.
The new controls seem to get created as I can access their values such as .top, .left, etc both in a message box and in the debugger,
But they won’t display on the form. I have Enabled, made Visible, put text in the Text attribute, refreshed and reShown the window, but they just don’t display.
I’ve shown the code below. Also, I seem to have to pre-size the variable that is used with the NEW directive. I.e. I have to give it dimensions. If I use () or (-1), I get runtime errors complaining about out-of-bounds indexes! There must be a way to declare it with no dimensions so it is truly dynamic?
Any help would be appreciated. I’m avery experienced programmer, but new to XOJO…Thanx…Markp
Code:
dim myFile as FolderItem
dim d as opendialog
d = new opendialog
dim t as TextInputStream
dim FirstLine as String
dim TwoCharNums() as String
dim Cell, LMargin, TMargin, R, C, CellHeight, CellWidth, RowTop, LeftMargin as Integer
Dim MazePath(64) as MazePathT
NumCols = 0
NumRows = 0
myFile = d.ShowModal ’ Get the file containing the input parameters for the maze
if myFile = nil then
MsgBox “You must select an input file containing the parameters that define the Maze.”
Return
Else
t = TextInputStream.Open(myFile)
FirstLine = t.ReadLine
TwoCharNums = FirstLine.Split(",") ’ Parse the first line into two strings
if Ubound(TwoCharNums) = 1 then ' Make sure we got two numbers
NumCols = cdbl(TwoCharNums(0))
NumRows = cdbl(TwoCharNums(1))
Else
msgbox "It appears the first line of the selected file does not contain a width and height specification in the form: 8,10. The value found is: " + EndOfLine + FirstLine
Return
End If
End If
’ We now know how big the maze should be, so create the visual maze on the screen first, then read the rest of the input file to get the pattern for the maze
Cell = 0
LMargin = MazePathT(0).left ’ This is set as a Member of MazePathT, index 0 in the IDE
TMargin = MazePathT(0).top
CellHeight = MazePathT(0).Height
CellWidth = MazePathT(0).Width
For R = 1 to NumRows
RowTop = TMargin +((R-1) * CellHeight) + ((R-1) * 1)
For C = 1 to NumCols
LeftMargin = Lmargin + ((C-1) * CellWidth) + ((C-1) * 1)
Cell = Cell + 1
MazePath(Cell) = New MazePathT(0)
MazePath(Cell).Left = LeftMargin
MazePath(Cell).Top = RowTop
MazePath(Cell).Enabled = True
MazePath(Cell).Visible = True
MazePath(Cell).Text = str(Cell)
MazePath(Cell).Border=True
Next
msgbox "Top = " + str(MazePath(Cell).Top)
Next