Addon Release: IsNewValue

All new Coranto Addons, updates and patches to addons, will be released here...also, get support for addons within!

Moderators: Spunkmeyer, Dale Ray, SrNupsen, Bluetooth, Jackanape

Addon Release: IsNewValue

Postby Parahead » Sat Feb 12, 2005 4:30 pm

This is an addon that is a direct response to the discussion in this and this thread. The first thread includes a nice example by sstoner which demonstrates the grouping of newsitems which this addon can help you with.

Anyway, within a normal Coranto installation you have the possibility to use these tags in a style which all is quite selfexplainatory:
Code: Select all
<If: Sub: isNewDate>
<If: Sub: isNewYear>
<If: Sub: isNewMonth>
<If: Sub: isNewWeek>
<If: Sub: isNewUser>
<If: Sub: isNewCategory>
<If: Sub: isNewFile>


With this addon you can use this tag in your style:
Code: Select all
<If: Sub: isNewValue: NameOfField>

Where the NameOfField is what it says, the name of the field you which to monitor if it has changed since the last newsitem in the current profile. So basically this addon replaces the above built in tags and gives you the full power to specify an arbitrary field to use without any restrictions, thus you can sort on a field of your choice and use the isNewValue tag to group the newsitems with a common header.

Sounds complicated? Well, if you didn´t understood the reference threads or what I mumbled about above, just don´t download it. But if you did understand my line of thinking and see the potential, feel free and download it. The addon is developed on a installation running Coranto 1.30.x but it should be fully functional with any release of Coranto.

Download here!
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Psykosys » Thu Feb 17, 2005 3:59 am

Very spiffy, thanks! I have a project that probably needs exactly this addon.
Psykosys
 
Posts: 252
Joined: Tue Apr 15, 2003 10:37 pm
Location: Ithaca, NY

Postby Dale Ray » Thu Mar 10, 2005 8:02 pm

This addon is not limited to testing the value of one field.

You can use perl code to create a string out of the values of multiple fields and then test that value. I use this to keep duplicates from printing in a profile that prints game schedules for softball. I put the two team names, the text separator, time, etc. into one string called $game ending up with this:

Team One at Team Two, 4 p.m.

and then use:

<If: Sub: isNewValue: game><Field: game></If>

to make sure it is not the same as the entry before.

If you want you can create a profile to just list the duplicates into a text file so you can easily find them and delete them.

I am entering the schedules for 45 high school teams (in two sports) so it easy to enter a duplicate, this makes it easy to spot them.
Dale Ray
User avatar
Dale Ray
 
Posts: 1004
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Gansos » Tue Sep 27, 2005 2:53 am

I've been using this addon to do some great things. In the process, I discovered an interesting fact that may not be apparent at first. This is a bit technical, so if you don't know PERL, you may get confused. For people who do understand PERL, this may be helpful.

Due to PERL's lazy evaluation of AND/OR operators, the following code may not perform as expected:
Code: Select all
<PerlCode>
if( isNewValue('SomeField' || isNewValue('SomeOtherField' ) {
  ...do something...
}
</PerlCode>

If the left side is true, PERL never evaluates the right side. This can be troublesome because isNewValue('SomeOtherField' ) never runs, and thus the value is not updated. The same is true for AND (&&) tests as well, except that if the left side is false, the right side is not evaluated.

The proper way to carryout such an operation would be this:
Code: Select all
<PerlCode>
$somevalue{$ProfileName} = isNewValue('SomeField');
$someothervalue{$ProfileName} = isNewValue('SomeOtherField');
if( $somevalue{$ProfileName} || $someothervalue{$ProfileName} ) {
  ...do something...
}
</PerlCode>

Now, both isNewValue tests run regardless of the logical operator tests. This is probably the desired behavior if you're using isNewValue in a logical test, like above.
Gansos
 
Posts: 62
Joined: Thu Jan 11, 2007 8:33 pm


Return to Addon Release and Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron