Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Math using Xpos, Ypos (Read 5933 times)
Paul Walters
Ex Member




Math using Xpos, Ypos
Mar 18th, 2009, 3:11pm
 
I need to do some math using Xpos and Ypos.  My sample file has two numeric attributes: BigXpos and BigYpos.  My agent has this action:

$BigXpos=0;$BigYpos=0;$BigXpos=$Xpos*50;$BigYpos=$Ypos*50

No matter what Xpos and Ypos are, my results are BigXpos=-100 and BigYpos=-100.  If I change 50 to 100, the results are BigXpos=-1000 and BigYpos=-1000.

I see why this is happening, if I change the agent to

$BigXpos=$Xpos;$BigYpos=$Ypos

My results (for Xpos=8.5 and Ypos=-4) are BigXpos=-2 and BigYpos=-2.

I sent a sample file to Eastgate support.

(I also tried eval() with the same results)
Back to top
 
« Last Edit: Mar 18th, 2009, 3:16pm by Paul Walters »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Math using Xpos, Ypos
Reply #1 - Mar 18th, 2009, 7:19pm
 
I don't get the same as you but I don't get the correct/expected results. As of v4.6, aliases now have their own values for some attributes such as Xpos & YPos to allow dashboard type effects. I had assumed that

$BigXpos(original)=$Xpos*50;$BigYpos(original)=$Ypos*50

...might work but it doesn't seem to. This might need some further clarification as to how the original aliases scope works with respect to aliases and intrinsic values.


Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Paul Walters
Ex Member




Re: Math using Xpos, Ypos
Reply #2 - Mar 18th, 2009, 7:58pm
 
This works (thanks to Mark B for his offline guidance):

$BigXpos=$Xpos(original)*50;$BigYpos=$Ypos(original)*50;


Back to top
 
« Last Edit: Mar 18th, 2009, 7:59pm by Paul Walters »  
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Math using Xpos, Ypos
Reply #3 - Mar 18th, 2009, 8:27pm
 
Since this is an agent's OnAdd action, the original statement

    BigXpos=$Xpos*50

sets BigXpos based on the xpos of the newly-created alias.  

Mark Anderson's idea is almost right, but not quite: $BigXpos for an alias and its original are identical.  That's true for almost everything!  But for a few attributes, it doesn't make sense for an alias to share with the original.  In particular:

    Xpos, Ypos, Height, Width

are distinct for an alias and its original; every time you move an alias, you don't want to also move the original!

Sp the correct action is

    BigXpos=$Xpos(original)*50;

Back to top
 
 
WWW   IP Logged
Paul Walters
Ex Member




Re: Math using Xpos, Ypos
Reply #4 - Mar 19th, 2009, 8:26am
 
For the avoidance of doubt, is it true that "original" always refers to the original non-aliased note?  So, if Agent-2 looks inside the results of Agent-1, which itself looked into MyContainer, it is the case that in Agent-2 an action that references Xpos(original) looks to a note inside MyContainer, and not to an alias in Agent-1.  N'est-ce pas?

(I'm working on a graphical export of a document with multiple layers of agents - so position matters.)
Back to top
 
« Last Edit: Mar 19th, 2009, 8:28am by Paul Walters »  
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Math using Xpos, Ypos
Reply #5 - Mar 19th, 2009, 12:14pm
 
Yes, original always refers to the underlying original note.
Back to top
 
 
WWW   IP Logged
Pages: 1
Send Topic Print