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
Get the word count of of children in an agent (Read 7893 times)
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Get the word count of of children in an agent
Jan 27th, 2010, 10:25am
 
Hi

I need a word count for some notes for a history project and I have created an agent that collects notes.

In these notes are paragraphs and I want to be able to see the total word count of all the children in the agent and push them to the display expression attribute.

Can you help? This is probably easy but I just want to make sure. If any of these is hard to understand please just say and I will try to make it clear

Thanks

Note: on Tinderbox 4.6.2, don't know if this will make a difference but I know there has been big changes since 4.6 so just in case.
Back to top
 
« Last Edit: Jan 27th, 2010, 10:27am by Sebastian Stephenson »  
Sebastian Stephenson sebey9   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Get the word count of of children in an agent
Reply #1 - Jan 27th, 2010, 12:43pm
 
Set this as your agent's $DisplayExpression:

$Name + "  (Wordcount: "+sum(child,$WordCount)+")"

For an agent called "Thesis" whose children's cumulative word count is 567, you'd see a title like "Thesis  (Wordcount: 567)".

I don't have v4.6.2 to hand but I do believe this will work with that version as we're not using any very new stuff here.

References: DisplayExpression, sum()
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Re: Get the word count of of children in an agent
Reply #2 - Jan 29th, 2010, 4:51pm
 
Hey does not seem to be working. I am putting it in the rule dialog box exactly like this

Quote:
$DisplayExpression="$Name + " (Wordcount: "+sum(child,$WordCount)+")"";


I added the extra quote at the end of comply with the very beginning quote

thank you for the help
Back to top
 
 
Sebastian Stephenson sebey9   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Get the word count of of children in an agent
Reply #3 - Jan 29th, 2010, 5:07pm
 
Ah, it depends where & how you set the DisplayExpression (DE). As an agent's Rename dialog has no DE box - unlike that of a note, I assumed you'd be setting via the Info view in which case the code supplied would work.

From your example it looks as though you used the agent's Rule to set the DE. In your example you actually at 2 quotes, not just one (one at each end). In such a contact where you need to quote the whole DE, you might find it clearer to use TB support for alternate quotes. For example:

$DisplayExpression='$Name + " (Wordcount: "'+sum(child,$WordCount)+')"';

Correction (see further below):

$DisplayExpression='$Name + " (Wordcount: "+'+sum(child,$WordCount)+'")"';

If you compare the two versions you'll see why #1 doesn't work. See if you can spot both errors.
Back to top
 
« Last Edit: Feb 3rd, 2010, 12:57pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Ioa Petra-ka
Full Member
*
Offline



Posts: 103
Portland, Oregon, USA
Re: Get the word count of of children in an agent
Reply #4 - Jan 29th, 2010, 5:09pm
 
That won’t work the way you’ve posted it. You don’t need to wrap the whole thing in quotes. Try to visualise what you are telling the expression by breaking it down into on/off sequences:

Code:
"$Name +"  
 (Wordcount:
"+sum(child,$WordCount)+"
)
"" 



As you can see, all of your code is ending up inside strings, and all of the stuff that is supposed to be strings is trying to get understood as code. The plus symbols bind string and code elements together.

Code:
"Test: " + $Name 



Note how the non-code element, “Test: ” is inside quotes, and then bound to then `$Name` attribute with a plus sign.

Update: And yes, if you were trying to embed the entire expression as a string to be evaluated later, definitely use Mark's example of alternative quote types.
Back to top
 
« Last Edit: Jan 29th, 2010, 5:11pm by Ioa Petra-ka »  

Av
  IP Logged
AGHorne
Full Member
*
Offline



Posts: 116

Re: Get the word count of of children in an agent
Reply #5 - Jan 29th, 2010, 5:11pm
 
I'm probably completely wrong, but is $DisplayExpression needed?

$Name + "("+Wordcount: +"sum(child,$WordCount)"+")"

Perhaps?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Get the word count of of children in an agent
Reply #6 - Jan 29th, 2010, 5:20pm
 
AG, read re-read my last post. It all depends where and how you try to set $DE.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Re: Get the word count of of children in an agent
Reply #7 - Jan 29th, 2010, 5:55pm
 
this is strange its working as in the info palette, it shows the number but in the actaully display of title on the agent it is
Quote:
"Title" (Wordcount:


any ideas?
Back to top
 
 
Sebastian Stephenson sebey9   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Get the word count of of children in an agent
Reply #8 - Jan 29th, 2010, 6:30pm
 
OK, when you enter the code from my first answer, into Info view in the General group's DisplayExpression box, what do you do see? To make sure you don't get old code hanging around, delete the existing DE before you copy/pasts code from my earlier answer.
Back to top
 
« Last Edit: Jan 29th, 2010, 6:33pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Re: Get the word count of of children in an agent
Reply #9 - Feb 3rd, 2010, 11:07am
 
Hey I removed the code form the rule field and the display expression field(in the info window) and I entered the first piece of code you gave me into the info field and it worked(showing on the note) but I tried it in the rule box and it did not work(I even tried the other code with the correct quotes and that did not work either) but it is showing result perfectly in the info window but not showing on the note.

Anyone know why?
Back to top
 
 
Sebastian Stephenson sebey9   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Get the word count of of children in an agent
Reply #10 - Feb 3rd, 2010, 12:53pm
 
METHOD #1: Direct Entry
  • Display Expression box of a note Create/Rename dialog
  • Info View, General Group, DisplayExpression, right column value box
Use: $Name + "  (Wordcount: "+sum(child,$WordCount)+")"

METHOD #2: Set via action code
  • Note or agent Rule
  • A note's dialog OnAdd or agent's dialog AgentAction box
Use: $DisplayExpression='$Name + " (Wordcount: "+'+sum(child,$WordCount)+'")"';
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Get the word count of of children in an agent
Reply #11 - Feb 3rd, 2010, 1:04pm
 
Here's a quick demo of each method listed in the post above.
Back to top
 
« Last Edit: Feb 3rd, 2010, 1:07pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sebastian Stephenson
Full Member
*
Offline



Posts: 100

Re: Get the word count of of children in an agent
Reply #12 - Feb 7th, 2010, 4:44pm
 
Great! it works sorry for the late reply, bizarre how troublesome this was. Shocked
Back to top
 
 
Sebastian Stephenson sebey9   IP Logged
Pages: 1
Send Topic Print