Not sure if these are bugs or just mis-use but at least one of them seems to contradict the Help File. Given the following program:
Program ShowProblems
Constant MaxTasks As Integer = 100
Define TaskList As TaskRecord [ MaxTasks ]
Class TaskRecord
Define TaskValue As Integer = 0
Method setValue (val As Integer)
This.TaskValue = val
End Method
Function getValue() As Integer
Return This.TaskValue
End Function
End Class
Method Main()
Define task As TaskRecord
Define I As Integer
For I = 1 To 3
task.setValue(I)
TaskList[I] = task
Next
For I = 1 To 3
task = TaskList[I]
PrintLine("Entry " + I + " has value of " + task.getValue())
Next
End Method
End Program
There are two issues:
1. Although the 'compiler' accepts the constant MaxTasks as the dimension for the array on line 4, at run time the program stops at this line saying that 'Index was outside the bounds of the array'. If I change to using the value 100 in the array declaration then it works fine.
2. How do class assignments work in Phrogram? It seems that they work by reference rathr than value since the final loop in the above prints out the following:
Entry 1 has value of 3
Entry 2 has value of 3
Entry 3 has value of 3
which suggests that all three entries in the array are 'pointing' at the same instance of TaskRecord (i.e. task). This is not necessarily wrong but it is a critical thing to know and I could not find any reference to how class/structure assignmenst work anywhere.
Please clarify both above points please.
Thanks, Chris