Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Questions and Answers >> Inheritance of attributes of parent
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1464426315

Message started by Rigas Arvanitis on May 28th, 2016, 5:05am

Title: Inheritance of attributes of parent
Post by Rigas Arvanitis on May 28th, 2016, 5:05am

Hi
(sorry its an easy one but I dont find the solution).
I have a Prototype "Lots of tasks" that contains Task notes
Prototype wants you to create a task that has today's date and the following attributes:
if ($StartDate==empty) {$StartDate=today};
if ($DansProjet==empty) {$DansProjet=$DansProjet(parent)};
if ($TimelineBand==empty){$TimelineBand=$TimelineBand(parent)}

Apart from the date, all the other instructions simply do not translate in the attributes of the new Task note. Am I wrong with the "parent" deisgnator?

Any idea what am I doing wrong?

Thank you all !

Title: Re: Inheritance of attributes of parent
Post by Mark Bernstein on May 28th, 2016, 8:09am

"empty" is a string with five letters.  I expect you mean

    if ($DansProjet=="") {$DansProjet=$DansProjet(parent)};

unless $DansProject is a string attribute with a default value of "empty".  Even then, empty should be surrounded by quotes because itís a string.

Why does the $StartDate rule not fail, too?  Tinderbox knows it's comparing dates, so it silently changes the rule to be

   if ($StartDate==date("empty")) {$StartDate=date("today")};

"empty" isn't something that date() understands, so date("empty") is "never" -- the default for $StartDate.

Title: Re: Inheritance of attributes of parent
Post by Rigas Arvanitis on May 28th, 2016, 9:40am

YES !!!

Master Bernstein, you are right (as always).

Thanks

Title: Re: Inheritance of attributes of parent
Post by Desalegn on Jun 10th, 2016, 4:48pm


Quote:
if ($StartDate==date("never")) {$StartDate=date("today")};

is not printing the day as value to my $StartDate attribute. I don't know what mistake I am making.


Title: Re: Inheritance of attributes of parent
Post by Mark Anderson on Jun 10th, 2016, 5:24pm

That works for me (in v6.1.).†Have you tested to code on its own? †Make a new file, add a note and set the $OnAdd to that code. †then make a new note, set $StartDate as a key attribute and drag it into the container. When I do this the date is set correctly.

The most likely thing at this point is some other code (agent, rule, etc) may be acting on the note. The above test should resolve that issue. If the test fails, I'd close/re-open Tinderbox and try again. If it still fails if must be something more obscure. I don't think locale affects date designators - i.e. "today" works the same on a US, French, Russian, etc. OS locale system.

//edits - typos

Title: Re: Inheritance of attributes of parent
Post by Desalegn on Jun 12th, 2016, 5:53am

Hi Mark, yes, it worked. I was trying to do it using Prototypes. Why do you prefer to a Container?

I was putting the $addOn on the prototype; and the $StartDate attribute to the notes I am creating with that prototype. Indeed, assigning the $AddOn on the containers isn't problem for me either. Thanks for explaining it.


[Mod: I think you mean $OnAdd rather than $addOn!]

Title: Re: Inheritance of attributes of parent
Post by Mark Anderson on Jun 12th, 2016, 6:44am

The use of a container is incidental. It was just simple method to specifying a minimal test for the code. The test works and has flushed out more circumstantial information , e.g. that you have prototypes involved.

Prototypes. If your prototype has a rule (or edict) like so:

if($StartDate==date("never")) {$StartDate=date("today")};

The the rule will run in the prototype, set $StartDate to the date/time the first time the code ran. That value will never change and all notes using the prototype will inherit the same $StartDate. In effect, the rule is broken - albeit unintentionally.

The $RuleDisabled attribute is there for just this sort of scenario. It is false by default (i.e. rules run by default) and it's value is never inherited - for reasons that should come apparent.

To use a prototype to set a rule like above, you first need to ensure the rule never fires in the prototype. The easiest way to do this is to select the prototype and open the Rule Inspector: un-tick the 'Enabled' box (this sets $RuleDisabled to true). Do this before adding any rule code. In an existing document you may have rule code already set up, so may need to reset any affected attributes that the rule may change when run.

Now, because the rule is suppressed in the prototype, it is run for the first time in each inheriting notes.

Title: Re: Inheritance of attributes of parent
Post by Desalegn on Jun 12th, 2016, 12:55pm


Quote:
The the rule will run in the prototype, set $StartDate to the date/time the first time the code ran. That value will never change and all notes using the prototype will inherit the same $StartDate. In effect, the rule is broken - albeit unintentionally.

now, I understand my mistake. Thank you Mark, as always!

Title: Re: Inheritance of attributes of parent
Post by Mark Anderson on Jun 12th, 2016, 2:50pm

No 'mistake' on your part! $RuleDisabled is there exactly because sometimes normal attribute inheritance gives us unintended results.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.