[Gambas-user] Two many objects and two many forms
Bruce
bbruen at ...2308...
Thu Oct 11 08:19:02 CEST 2012
:-Q
I have a collection of objects, of two types, both of which inherit from
the same superclass, "ActionItem". One is a query, i.e. an object
whose .CmdString is an SQL string; and the other is a command,
whose .CmdString is a Shell string. IOW:
ActionItem
^
|
________________________________________
| |
ActionQuery ActionCommand
The only difference between ActionQuery and ActionCommand is they have
different code for the "Exec" method in each of them. (That either
executes the query against the database on one hand and acts on the
results or Shells the command "To" and interprets the return. That bit
works fine.)
What I cant work out is this.
I have, by necessity, two editor forms that allow the user to configure
the "ActionItems" in the collection. (They are both fairly similar
visually but have quite different internal code.)
The user is presented with a list of the ActionItems in the main form
and can select one and activate it's editor.
Public Sub mnuEditAction_Click()
Dim fec As FEditCommand
Dim feq As FEditQuery
Dim wkform As Form
Dim wkAction As CActionItem
If lvwActionList.Current.Selected Then
wkAction = $actions[lvwActionList.Key]
If wkAction.ActionType = "Command" Then
fec = New FEditCommand
fec.ActionItem = wkAction
wkform = fec
Else
feq = New FEditQuery
feq.ActionItem = wkAction
wkform = feq
Endif
If wkform.Run("Edit") Then <---- FAILS HERE
wkform.ActionItem.Save
If wkform.ActionItem.Name = lvwActionList.Key Then
$actions[lvwActionList.Key] = wkform.ActionItem
Else
$actions.Add(wkform.ActionItem, wkform.ActionItem.Name)
$actions.Remove(lvwActionList.Key)
Endif
LoadActionList
Endif
Endif
End
The code fails with "Unknown Symbol 'Run' in class 'Form'". But both
FEditCommand and FEditQuery have
Public Sub Run(Type As String) As Boolean
methods.
The debugger shows wkform as the correctly subclassed form (i.e.
FEditCommand or FEditQuery).
Any suggestions welcome.
tia
Bruce
More information about the User
mailing list