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
Checking code upgrade (Read 2588 times)
Stephen Hay
Full Member
*
Offline



Posts: 61
Wellington NZ
Checking code upgrade
Jun 05th, 2015, 7:00pm
 
Hello again,

This is code that worked fine in Tbx 5 and seems to work okay in TB6.

if($CriticalFew="true"){$NextContact=$LastContact+"7weeks"} else {$NextContact=$LastContact+"3months"};$StartDate=$LastContact

The $StartDate part is so I can use Timeline to see my network over time.

Is it still correct, though?

Thanks,
Stephen
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Checking code upgrade
Reply #1 - Jun 6th, 2015, 4:29am
 
The if condition only works because of legacy syntax support. In an if() query, use == to test equality of 2 things.  Also, boolean true values are lowercase true/false and not quoted.

A better syntax for the date maths is $SomeDate = date($AnotherDate + "4 weeks") - see more.

if($CriticalFew==true){$NextContact=date($LastContact+"7weeks")} else {$NextContact=date($LastContact+"3months")};$StartDate=$LastContact

This is the above, just laid out in easier-to-read form for later readers:

if($CriticalFew==true){
   $NextContact=date($LastContact+"7weeks")
} else {
   $NextContact=date($LastContact+"3months")
};
$StartDate=$LastContact


Note that a single - or the last - expression in {} sections don't need a semi-colon terminator, nor does the last expression. But we do need a semi-colon after the lat } of the if clause as it is the end of that expression and a separate expression follows (@Stephen got all that part right lest I imply otherwise).
Back to top
 
 

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



Posts: 61
Wellington NZ
Re: Checking code upgrade
Reply #2 - Jun 6th, 2015, 7:00pm
 
Thanks, Mark but credit where credit is due. Given my coding abilities, it is most likely that you provided me with the v5 code in the first place...
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Checking code upgrade
Reply #3 - Jun 6th, 2015, 7:46pm
 
No worries. In trying to suggest 'best practice' it's all too easy to appear pedantic. Web pages live a long time and there are plenty of old code examples around for an app that's now 15 years old.  Smiley

For later reader, I'd comment the tutorials/walkthroughs (written by Mark B) in the app's Help menu. For my own efforts, I've tried to weed legacy code from the v6 aTbRef.  I'm not totally done revising and am very happy to hear of pages that are ambiguous in this regard; there are >3.5k sourece notes so it's hard to re-read everything regularly.
Back to top
 
« Last Edit: Jun 6th, 2015, 7:46pm by Mark Anderson »  

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