Still working on the Gravitational Simulator, I found an instance of Control Object Value oddity. The following is part of the SUB __UI_KeyPress (id AS LONG) (Code here will not function as only relevant lines included):
'When this event is fired, __UI_KeyHit will contain the code of the key hit.
'You can change it and even cancel it by making it = 0
PRINT #2, id
, HowManyBodiesTB
CtrlIndex% = WhichIsIt%(id)
IF VAL(Text
(HowManyBodiesTB
)) >= 2 AND VAL(Text
(HowManyBodiesTB
)) <= 11 THEN Control(BodyDataFR).Hidden = False
SetFocus BodyMass1TB
Index%
= VAL(Text
(HowManyBodiesTB
))
PRINT #2, Index%
, Text
(HowManyBodiesTB
), id
, Text
(id
), CtrlIndex%
, HowManyBodiesTB
FOR K%
= 8 * M%
- 7 TO 8 * M%
The control HowManyBodiesTB has just had a carriage return, and the program enters the SUB. The value of HowManyBodiesTB is 54, and I convert this into the number CtrlIndex% whose value is 89. The SELECT CASE CtrlIndex% enters position CASE 89 and the program errors at the FOR/Next loop at the end. I have added some extra lines to output values to a text file. The output values are:
54, 54
54
5, 5, 64, (blank), 89, 54
In order these are the values of:
id, HowManyBodiesTB
id
Index%, Text(HowManyBodiesTB), id, Text(id), CtrlIndex%, HowManyBodiesTB
From the first two lines we see that id = HowManyBodiesTB = 54 as expected
From the third line we see:
The value of Index% = 5; Text(HowManyBodiesTB) = "5" as expected
id = 64 Changed from 54 for no reason
Text(id) is blank because id is no longer 54 !!!
I have no idea why this is happening. Nothing occurs between where id = 54 and where id = 64.
Any ideas?