trying to understand Longmove
Blake Koch
Posts: 39
If I'm writing a program that has two objects running in two separate cogs. The first cog has Global VAR long a,b,c declared, I then want Longmove(@a,@ABC,3) to cog two.
here is my question.
How do I move @ABC back into Var a,b,c in cog two so I could then use these variable for something else.
thanks
Blake
here is my question.
How do I move @ABC back into Var a,b,c in cog two so I could then use these variable for something else.
thanks
Blake
Comments
You may need to add similar methods to each object so that the parent object can move data directly between the two.
Sending Object (cog 2)
object 1
VAR
LONG a,b,c,
PUB Something(ABC)
longmove(ABC,@a,3)
In the Receiving Object ( cog 1) I just have to Call Object1, the method and the address of the global variable.
object2
PUB Something_else | a,b,c
object1.Something(@ABC)
a + b + c := d
Then I could use (d = a+b+c) or some other manipulation of a,b or c.
In ObjectA, put the variables you want to share together an in order; let's say they are called first, second, and third. Create a method called shared in ObjectA. The next step is to create a method in ObjectB (which does the work on the variables originating in ObjectA) that gets the shared address of ObjectA via the main app. The main application does this: Now ObjectB knows where the ObjectA values are stored and can manipulate them. ObjectB can make local copies of the ObjectA variables like this: Remember, shared is an address so you don't need to use @ with it in this case. ObjectB can put values back by reversing the source and destination terms. Variable names are pleasant ways to deal with variable addresses. Once you know where the variables are located in RAM, you can directly affect them. For example, if ObjectB wanted to add ObjectA's first and second variables and store the result in the third, you could do this. It's not pretty, but it works.