[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
createActionTo question/error
From: |
Ken Cline |
Subject: |
createActionTo question/error |
Date: |
Sat, 5 Jul 1997 00:16:35 -0400 (EDT) |
Hi all!
I don't seem to be able to execute actions that use 2
arguments. Is this not supported yet?
In particular, I create the following action with no
problems:
[ displayActions createActionTo: self
message: M(updateHisto:)
: (id)aHisto
: (id)aList ];
But when the action is executed by the schedule, I get the
following error:
error: AgentObserver (instance)
AgentObserver does not recognize updateHisto:
Abort (core dumped)
I interpret this to mean that the Schedule class does not
support actions with 2 arguments. Or perhaps I am doing
something wrong?
I have a "work around" that stores the second argument in a
static variable (with file scope) and then I create an
action which only requires 1 argument. That is:
static id tempList = aList;
and
[ displayActions createActionTo: self
message: M(updateHisto:)
: (id)aHisto ];
This works but it isn't a good solution.
If it isn't possible to execute actions which have 2
arguments then I would probably try storing the second
argument inside a subclass of Histo. (I would, of course,
have to create that subclass first.)
FYI, here's a little more of context within which I was
trying to schedule the "updateHisto" action:
-(void) buildHistoFor: (id <List>) aList {
Histo * aHisto = NULL;
/*****
* Setup the histogram
*****/
aHisto = [ Histo create: [self getZone] ];
... Histo setup ...
[ aHisto pack ];
/*****
* Schedule the update of the histogram
*****/
[ displayActions createActionTo: self
message: M(updateHisto:)
: (id)aHisto
: (id)aList ];
}
-(void) updateHisto: (id) aHisto : (id) aList {
[ aHisto drawHistoWithInt: [agent getDataFor: aList] ];
}
As I was writing this I tried out some other ideas...
It appears as if
[ displayActions createActionTo: self
message: M(updateHisto:)
: (id)aHisto
: (id)aList ];
is actually dropping the last argument. That is, it is
equivalent to:
[ displayActions createActionTo: self
message: M(updateHisto:)
: (id)aHisto ];
Because, when I provide the following method:
-(void) updateHisto: (id) aHisto {
printf("Test!\n");
}
I see this function called even though I created the action
with 2 arguments (i.e. aHisto and aList).
Thanks for any help.
Ken.
PS: My apologies for this rather confusing post; it sort of
reflects of my current state of mind.
======================================================
Complete code for the "buildHistoFor:" method:
-(void) buildHistoFor: (id <List>) aList {
int numPoints = [ aList getCount ];
char * labels[ numPoints ];
char * colors[ numPoints ];
id <subAgent> subAgent = NULL;
id <ListIndex> aListIndex = NULL;
int i = 0;
Histo * aHisto = NULL;
/*****
* Make sure we have a a displaySchedule and
* and ActionGroup
*****/
if ( displaySchedule == NULL )
[ self buildDisplaySchedule ];
if ( displayActions == NULL ) {
displayActions = [ ActionGroup create: [self getZone] ];
[ displaySchedule at: getCurrentTime()
createAction: displayActions ];
}
/*****
* Use the List to setup the "labels" and "colors"
* arrays need to setup the histogram
*****/
aListIndex = [ aList begin: [self getZone] ];
for ( i = 0; i < numPoints; i++ ) {
if ( [aListIndex getLoc] == End ) {
labels[ i ] = "?";
colors[ i ] = "black";
}
subAgent = [ aListIndex next ];
if ( subAgent == NULL ) {
labels[ i ] = "?";
colors[ i ] = "black";
}
else {
labels[ i ] = [ subAgent getAgentName ];
if ( [subAgent respondsTo: M(getAgentColor)] == TRUE )
colors[ i ] = [ subAgent getAgentColor ];
else
colors[ i ] = "black";
}
} // end For-loop
/*****
* Setup the histogram
*****/
aHisto = [ Histo create: [self getZone] ];
[ aHisto setWidth: 600
Height: 400 ];
[ aHisto setNumPoints: numPoints
Labels: labels
Colors: colors ];
[ aHisto title: "Agent Data" ];
[ aHisto axisLabelsX: "Agent"
Y: "Share" ];
[ self updateHisto: aHisto : aList ];
[ marketShareHisto pack ];
/*****
* Schedule the update of the histogram
*****/
[ displayActions createActionTo: self
message: M(updateHisto:)
: (id)aHisto
: (id)aList ];
}
_________________________________________________________
Ken Cline address@hidden
SAIC VOICE (410) 571-0413
Annapolis, MD FAX (301) 261-8427
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================
- createActionTo question/error,
Ken Cline <=