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
Inheritance of attributes of parent (Read 1306 times)
Rigas Arvanitis
Full Member
*
Offline



Posts: 101
Paris (France)
Inheritance of attributes of parent
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 !
Back to top
 
 

Rigas Arvanitis
WWW   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Inheritance of attributes of parent
Reply #1 - 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.
Back to top
 
 
WWW   IP Logged
Rigas Arvanitis
Full Member
*
Offline



Posts: 101
Paris (France)
Re: Inheritance of attributes of parent
Reply #2 - May 28th, 2016, 9:40am
 
YES !!!

Master Bernstein, you are right (as always).

Thanks
Back to top
 
 

Rigas Arvanitis
WWW   IP Logged
Desalegn
Full Member
*
Offline



Posts: 78
Norway
Re: Inheritance of attributes of parent
Reply #3 - 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.

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Inheritance of attributes of parent
Reply #4 - 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
Back to top
 
« Last Edit: Jun 12th, 2016, 6:45am by Mark Anderson »  

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



Posts: 78
Norway
Re: Inheritance of attributes of parent
Reply #5 - 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!]
Back to top
 
« Last Edit: Jun 12th, 2016, 6:29pm by Mark Bernstein »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Inheritance of attributes of parent
Reply #6 - 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.
Back to top
 
 

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



Posts: 78
Norway
Re: Inheritance of attributes of parent
Reply #7 - 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!
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Inheritance of attributes of parent
Reply #8 - Jun 12th, 2016, 2:50pm
 
No 'mistake' on your part! $RuleDisabled is there exactly because sometimes normal attribute inheritance gives us unintended results.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print