Either this is a problem caused by Alpha's non-zero based arrays or A5V10 is having a problem with sub-properties. I'm not sure which. The objective is to allow a user to directly move items and nodes in a tree as he wishes, which is especially handy functionality for anyone interested in outlining or document management.
Here's the error message:
Probably the easiest way to understand this problem is to take a quick look at the attached Jing video, which shows an extremely simple example both using MS Access and A5V10. Access works; A5V10 using the same code does not. The only difference between the code is using ( ) for Access and [ ] for A5V10.
Here�s the link: http://www.screencast.com/t/MjEzZTVjOW
In it, the user is able to easily reposition a line in a grid, moving it up or down a hierarchical grid as desired. The example was built using an ActiveX control ExGrid from Exontrol.com.
To keep this example simple, all records are at the same level in the hierarchy.
When the MS Access form is loaded, the following variables are defined:
Note that Microsoft Access recognizes that HITEM when the dimension statement is written as shown in the screen print below.
The control�s documentation states:
When the UP button is pushed, the following code executes:
When the DOWN button is pushed, the following code executes:
Here�s a brief explanation what the control is doing:
The handle represents number generated by the ActiveX control which appears to be a large integer to uniquely identify each item in the grid. The item position represents the sequential number of the child item displayed in the grid.
For example, displaying this information for the first line in message boxes
might show the following values:
myHandle = 136453920
myItemPosition = 0
When the exercise is repeated, the value of myHandle is randomly changed, for example:
myHandle = 136451800
myItemPosition = 0
or when repeated one more time:
myHandle = 136433168
myItemPosition = 0
The value of myHandle remains constant for a session, even though the MyItemPositon value can increase/decrease as the appropriate button to move the focus Up or Down
Now let�s try to make this work with Alpha Five, remembering Selwyn�s guidance that in A5 arrays require square brackets [ ] and are based on 1 and not zero as is the case for Visual Basic.
The following A5V10 code, a simple rewrite of VB to XBasic, is placed behind the OnInit event:
The following code is placed behind the DOWN button
The following code is placed behind the UP button
When the up or down button�s are clicked, Alpha displays the following error message:
Script:OnPush:12
Grid1.Items.ItemPosition[myHandle] = myHandle -1
Property not found
Grid1.Items Subproperty can not be assigned to
The only difference between the MS Access and A5 code is the use of square brackets.
Also note that even though I attempted to dimension mHandle As HITEM just like in the Access example, A5 errored with the following message:
Script:OnInit line:14
dim mHandle As HITEM
Type is not defined
Therefore I redefined it as N.
I don't see anything wrong with my use of subproperties, that is if something worked in MS Access, I expect that it should also work with A5V10.
Is this an error of some sort on my part or a A5 bug?
Bob McGaffic
Pittsburgh, PA
Here's the error message:
Code:
Script:OnPush:12 Grid1.Items.ItemPosition[myHandle] = myHandle -1 Property not found Grid1.Items Subproperty can not be assigned to
Here�s the link: http://www.screencast.com/t/MjEzZTVjOW
In it, the user is able to easily reposition a line in a grid, moving it up or down a hierarchical grid as desired. The example was built using an ActiveX control ExGrid from Exontrol.com.
To keep this example simple, all records are at the same level in the hierarchy.
When the MS Access form is loaded, the following variables are defined:
Code:
Dim myHandle As HITEM Dim myItemPosition As Integer
The control�s documentation states:
Code:
HITEM A long expression that indicates the item's handle that indicates the newly created item.
Code:
�Move up myHandle = Grid1.Items.FocusItem myItemPosition = Grid1.Items.ItemPosition(myHandle) Grid1.Items.ItemPosition(myHandle) = myItemPosition � 1
Code:
'Move down myHandle = Grid1.Items.FocusItem myItemPosition = Grid1.Items.ItemPosition(myHandle) Grid1.Items.ItemPosition(myHandle) = myItemPosition + 1
The handle represents number generated by the ActiveX control which appears to be a large integer to uniquely identify each item in the grid. The item position represents the sequential number of the child item displayed in the grid.
For example, displaying this information for the first line in message boxes
might show the following values:
myHandle = 136453920
myItemPosition = 0
When the exercise is repeated, the value of myHandle is randomly changed, for example:
myHandle = 136451800
myItemPosition = 0
or when repeated one more time:
myHandle = 136433168
myItemPosition = 0
The value of myHandle remains constant for a session, even though the MyItemPositon value can increase/decrease as the appropriate button to move the focus Up or Down
Now let�s try to make this work with Alpha Five, remembering Selwyn�s guidance that in A5 arrays require square brackets [ ] and are based on 1 and not zero as is the case for Visual Basic.
The following A5V10 code, a simple rewrite of VB to XBasic, is placed behind the OnInit event:
Code:
dim global Grid1 as P Grid1 = Activex1.ActiveX.this dim myHandle As N dim myItemPosition As N Grid1.LinesAtRoot = -1 Grid1.Columns.Add("Default")
Code:
myHandle = Grid1.Items.FocusItem myItemPosition = Grid1.Items.ItemPosition(myHandle) Grid1.Items.ItemPosition[myHandle] = myHandle +1
Code:
myHandle = Grid1.Items.FocusItem myItemPosition = Grid1.Items.ItemPosition(myHandle) Grid1.Items.ItemPosition[myHandle] = myHandle � 1
Script:OnPush:12
Grid1.Items.ItemPosition[myHandle] = myHandle -1
Property not found
Grid1.Items Subproperty can not be assigned to
The only difference between the MS Access and A5 code is the use of square brackets.
Also note that even though I attempted to dimension mHandle As HITEM just like in the Access example, A5 errored with the following message:
Script:OnInit line:14
dim mHandle As HITEM
Type is not defined
Therefore I redefined it as N.
I don't see anything wrong with my use of subproperties, that is if something worked in MS Access, I expect that it should also work with A5V10.
Is this an error of some sort on my part or a A5 bug?
Bob McGaffic
Pittsburgh, PA
Comment