Re: [WebDNA] Data Type Bool
This WebDNA talk-list message is from 2009
It keeps the original formatting.
numero = 103159
interpreted = N
texte = --Apple-Mail-25-690537893Content-Type: text/plain;charset=US-ASCII;format=flowed;delsp=yesContent-Transfer-Encoding: 7bitSome handy techniques I use for dealing with boolean values...I define two global text variables in my header include files:[text]true=1=1[/text][text]false=1=0[/text]Then I use these to set my "boolean" variables within my code:[text]needToDoThis=[true][/text][text]alreadyDidThis=[true][/text]Then in my IF, SHOWIF and HIDEIF statements, I can use the following:[if [needToDoThis][then]do this[/then][else]don't do this[/else][/if][showif [needToDoThis]]do this[text]alreadyDidThis=[true][/text][/showif][hideif [alreadyDidThis]]gotta do this[/hideif]I don't use these values in my databases, because I prefer to avoid the confusion and need for URL'ing that can arise of sticking equals signs into my simple true / false values. I typically use T or F to represent true and false. I will sometimes do the following when interpreting these values for use in late logic:[text]tInStock=[if "[url][dbInStock][/url]"="T"][then][true][/then] [else][false][/else][/if][/text]Then I can use the following logic:[showif [tInStock]] ... [/showif]Brian FriesBrainScan SoftwareOn Aug 6, 2009, at 10:21 AM, Patrick McCormick wrote:> Sorry if I've just confused the heck out of everybody! Godiva is > right. I can remember doing this a while back, but I don't remember > if it worked this way, or if I had to do some setup.>> I experimented and [showif] currently requires an expression that > evaluates to true or false. I will make a feature request to modify > this so that true is anything greater than 0 and false is anything > less than 0. That'd be handy and powerful.>> You can get the same effect if you do a little setup work. I > frequently setup text variables like this:>> [text show=F&multi=T]checkStock=[raw][qty]>0[/ > raw]&inStock=[interpret][checkStock][/interpret][/text]>> From then on I can [showif [instock]]>> I usually put the setup variables in an include file which acts like > a list of definitions of various conditions. It's worth the trouble > because it makes my code more readable. After a while I start to > forget about the include file and believe that [showif [condition]] > just works natively. I done hypnotized myself.>> Pat>>> On Aug 5, 2009, at 12:37 PM, Govinda wrote:>>> I bottom posted, see below:>>>> On Aug 5, 2009, at 11:24 AM, Terry Wilson wrote:>>>>> Then what did you mean when you said:>>>>>>> > Be aware that something like [showif [instock]=1] is>>>> >the same as [showif [instock]] as long as [instock] is>>>> >greater than zero when an item is actually in stock. It>>>> >helps make the code a little bit more readable, too.>>>> there was discussion back around version 4 release (year 2000?) >> (IIRC) about [if] expressions taking advantage of boolean states >> behind the scenes, so that one could use code like what Patrick was >> referring to. In those days I did not pay enough attention about >> that to say more now... but if you wanted to look into the roots >> of this discussion, searching the old archives for what I am >> referring to would be a good start.>--Apple-Mail-25-690537893Content-Type: text/html;charset=US-ASCIIContent-Transfer-Encoding: quoted-printable
Some handy techniques I =use for dealing with boolean values...
I define two =global text variables in my header include =files:
[text]true=3D1=3D1[/text]
[text]false=3D=1=3D0[/text]
Then I use these to set my ="boolean" variables within my =code:
[text]needToDoThis=3D[true][/text]
[text]alreadyDidThis=3D[true][/text]
Then in my IF, SHOWIF and HIDEIF statements, I can use the =following:
[if =[needToDoThis][then]
=do this
[/then][else]
=don't do this
[/else][/if]
=[showif [needToDoThis]]
do this
=[text]alreadyDidThis=3D[true][/text]
[/showif]
=
[hideif [alreadyDidThis]]
gotta do =this
[/hideif]
I don't =use these values in my databases, because I prefer to avoid the =confusion and need for URL'ing that can arise of sticking equals signs =into my simple true / false values. I typically use T or F to represent =true and false. I will sometimes do the following when interpreting =these values for use in late =logic:
[text]tInStock=3D[if ="[url][dbInStock][/url]"=3D"T"][then][true][/then][else][false][/else][/if=][/text]
Then I can use the following =logic:
[showif [tInStock]] ... =[/showif]
Brian =Fries
BrainScan Software
On Aug =6, 2009, at 10:21 AM, Patrick McCormick wrote:
Sorry if I've just confused the =heck out of everybody! Godiva is right. I can remember doing this a =while back, but I don't remember if it worked this way, or if I had to =do some setup.
I experimented and [showif] =currently requires an expression that evaluates to true or false. = I will make a feature request to modify this so that true is =anything greater than 0 and false is anything less than 0. That'd be =handy and powerful.
You can get the same effect =if you do a little setup work. I frequently setup text variables =like this:
[text =show=3DF&multi=3DT]checkStock=3D[raw][qty]>0[/raw]&inStock=3D[i=nterpret][checkStock][/interpret][/text]
=46rom =then on I can [showif [instock]]
I usually =put the setup variables in an include file which acts like a list of =definitions of various conditions. It's worth the trouble because =it makes my code more readable. After a while I start to forget about =the include file and believe that [showif [condition]] just works =natively. I done hypnotized =myself.
Pat
On Aug 5, 2009, at 12:37 PM, Govinda wrote:
I bottom posted, see =below:
On Aug 5, 2009, at 11:24 AM, Terry Wilson =wrote:
Then what did you mean when you said:
> Be aware that something like [showif =[instock]=3D1] is
>the same as [showif [instock]] as long as =[instock] is
>greater than zero when an item is actually in =stock. It
>helps make the code a little bit more readable, =too.
<=br>
there was discussion back around version 4 release (year =2000?) (IIRC) about [if] expressions taking advantage of boolean =states behind the scenes, so that one could use code like what Patrick =was referring to. In those days I did not pay enough attention =about that to say more now... but if you wanted to look into the =roots of this discussion, searching the old archives for what I am =referring to would be a good =start.
=div>
=--Apple-Mail-25-690537893--
Associated Messages, from the most recent to the oldest:
--Apple-Mail-25-690537893Content-Type: text/plain;charset=US-ASCII;format=flowed;delsp=yesContent-Transfer-Encoding: 7bitSome handy techniques I use for dealing with boolean values...I define two global text variables in my header include files:[text]true=1=1[/text][text]false=1=0[/text]Then I use these to set my "boolean" variables within my code:[text]needToDoThis=[true][/text][text]alreadyDidThis=[true][/text]Then in my IF, SHOWIF and HIDEIF statements, I can use the following:[if [needToDoThis][then]do this[/then][else]don't do this[/else][/if][showif [needToDoThis]]do this[text]alreadyDidThis=[true][/text][/showif][hideif [alreadyDidThis]]gotta do this[/hideif]I don't use these values in my databases, because I prefer to avoid the confusion and need for URL'ing that can arise of sticking equals signs into my simple true / false values. I typically use T or F to represent true and false. I will sometimes do the following when interpreting these values for use in late logic:[text]tInStock=[if "[url][dbInStock][/url]"="T"][then][true][/then] [else][false][/else][/if][/text]Then I can use the following logic:[showif [tInStock]] ... [/showif]Brian FriesBrainScan SoftwareOn Aug 6, 2009, at 10:21 AM, Patrick McCormick wrote:> Sorry if I've just confused the heck out of everybody! Godiva is > right. I can remember doing this a while back, but I don't remember > if it worked this way, or if I had to do some setup.>> I experimented and [showif] currently requires an expression that > evaluates to true or false. I will make a feature request to modify > this so that true is anything greater than 0 and false is anything > less than 0. That'd be handy and powerful.>> You can get the same effect if you do a little setup work. I > frequently setup text variables like this:>> [text show=F&multi=T]checkStock=[raw][qty]>0[/ > raw]&inStock=[interpret][checkStock][/interpret][/text]>> From then on I can [showif [instock]]>> I usually put the setup variables in an include file which acts like > a list of definitions of various conditions. It's worth the trouble > because it makes my code more readable. After a while I start to > forget about the include file and believe that [showif [condition]] > just works natively. I done hypnotized myself.>> Pat>>> On Aug 5, 2009, at 12:37 PM, Govinda wrote:>>> I bottom posted, see below:>>>> On Aug 5, 2009, at 11:24 AM, Terry Wilson wrote:>>>>> Then what did you mean when you said:>>>>>>> > Be aware that something like [showif [instock]=1] is>>>> >the same as [showif [instock]] as long as [instock] is>>>> >greater than zero when an item is actually in stock. It>>>> >helps make the code a little bit more readable, too.>>>> there was discussion back around version 4 release (year 2000?) >> (IIRC) about [if] expressions taking advantage of boolean states >> behind the scenes, so that one could use code like what Patrick was >> referring to. In those days I did not pay enough attention about >> that to say more now... but if you wanted to look into the roots >> of this discussion, searching the old archives for what I am >> referring to would be a good start.>--Apple-Mail-25-690537893Content-Type: text/html;charset=US-ASCIIContent-Transfer-Encoding: quoted-printableSome handy techniques I =use for dealing with boolean values...
I define two =global text variables in my header include =files:
Then I use these to set my ="boolean" variables within my =code:
[text]needToDoThis=3D[true][/text]
[text]alreadyDidThis=3D[true][/text]
Then in my IF, SHOWIF and HIDEIF statements, I can use the =following:
[if =[needToDoThis][then]
=do this
[/then][else]
=don't do this
[/else][/if]
=[showif [needToDoThis]]
do this
=[text]alreadyDidThis=3D[true][/text]
[/showif]
=
[hideif [alreadyDidThis]]
gotta do =this
[/hideif]
I don't =use these values in my databases, because I prefer to avoid the =confusion and need for URL'ing that can arise of sticking equals signs =into my simple true / false values. I typically use T or F to represent =true and false. I will sometimes do the following when interpreting =these values for use in late =logic:
[text]tInStock=3D[if ="
[url][dbInStock][/url]"=3D"T"][then][true][/then][else][false][/else][/if=][/text]
Then I can use the following =logic:
[showif [tInStock]] ... =[/showif]
Brian =Fries
BrainScan Software
On Aug =6, 2009, at 10:21 AM, Patrick McCormick wrote:
Sorry if I've just confused the =heck out of everybody! Godiva is right. I can remember doing this a =while back, but I don't remember if it worked this way, or if I had to =do some setup.
I experimented and
[showif] =currently requires an expression that evaluates to true or false. = I will make a feature request to modify this so that true is =anything greater than 0 and false is anything less than 0. That'd be =handy and powerful.
You can get the same effect =if you do a little setup work. I frequently setup text variables =like this:
[text =show=3DF&multi=3DT]checkStock=3D
[raw][qty]>0[/raw]&inStock=3D[i=nterpret][checkStock][/interpret][/text]
=46rom =then on I can [showif [instock]]
I usually =put the setup variables in an include file which acts like a list of =definitions of various conditions. It's worth the trouble because =it makes my code more readable. After a while I start to forget about =the include file and believe that [showif [condition]] just works =natively. I done hypnotized =myself.
Pat
On Aug 5, 2009, at 12:37 PM, Govinda wrote:
I bottom posted, see =below:
On Aug 5, 2009, at 11:24 AM, Terry Wilson =wrote:
Then what did you mean when you said:
> Be aware that something like [showif =[instock]=3D1] is
>the same as [showif [instock]] as long as =[instock] is
>greater than zero when an item is actually in =stock. It
>helps make the code a little bit more readable, =too.
<=br>
there was discussion back around version 4 release (year =2000?) (IIRC) about
[if] expressions taking advantage of boolean =states behind the scenes, so that one could use code like what Patrick =was referring to. In those days I did not pay enough attention =about that to say more now... but if you wanted to look into the =roots of this discussion, searching the old archives for what I am =referring to would be a good =start.
=div>
=--Apple-Mail-25-690537893--
Brian Fries
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
Search wbrk word break param (1998)
WebCatalog.acgi quitting with error Type 2 (1998)
Price and Formula.db (2002)
Windows nt service pack 3 upgrade (1997)
Searching/sorting dates (1997)
repost: sending a down arrow (2000)
4.x in production update (2000)
Graphing Modules (2004)
[WebDNA] Still having problems (2008)
creator code (1997)
Webcat run amuk (2002)
Re:2nd WebCatalog2 Feature Request (1996)
Online magazine- monthly updates and such (1999)
Grant, please help me ... (1997)
Re:2nd WebCatalog2 Feature Request (1996)
WebCat b15 Mac plug-in (1997)
converted seed value? (1998)
Search inside Include (1998)
Snake Bites (1997)
Are you an WC expert? (1997)