Re: Control structure with "not"
You could: set tSwitchApple to (tSender is not "Apple") set tSwitchPeach to (tSender is not "Peach") set tSwitchGrape to (tSender is not "Grape") Slightly different than your code because the switches would be set to false if the condition isn't met whereas you code doesn't do that. On Tue, Aug 4, 2015 at 2:25 PM Peter Bogdanoff wrote: > Is it possible to convert this to a switch control structure, or otherwise > refined somehow? The “not” is what I need, and the setting has to be always > “true”: > > on doThisThing tSender > if tSender is not “Apple” then > set tSwitchApple to true > end if > > if Sender is not “Peach” then > set tSwitchPeach to true > end if > > if Sender is not “Grape” then > set tSwitchGrape to true > end if > end doThisThing > > Peter Bogdanoff > UCLA > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Control structure with "not"
One option, if I understand what you're asking: on doThisThing tSender repeat for each item theVar in "Apple,Peach,Grape" do "put (tSender <> theVar) into" && ("tSwitch" & theVar) end repeat end doThisThing Regards, Scott Rossi Creative Director Tactile Media, UX/UI Design On 8/4/15, 2:24 PM, "Peter Bogdanoff" wrote: >Is it possible to convert this to a switch control structure, or >otherwise refined somehow? The ³not² is what I need, and the setting has >to be always ³true²: > >on doThisThing tSender > if tSender is not ³Apple² then > set tSwitchApple to true > end if > > if Sender is not ³Peach² then > set tSwitchPeach to true > end if > > if Sender is not ³Grape² then > set tSwitchGrape to true > end if >end doThisThing > >Peter Bogdanoff >UCLA >___ >use-livecode mailing list >use-livecode@lists.runrev.com >Please visit this url to subscribe, unsubscribe and manage your >subscription preferences: >http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Control structure with "not"
Hi. Your if-then would be better served as: on doThisThing tSender if tSender is not “Apple” then set tSwitchApple to true else if Sender is not “Peach” then set tSwitchPeach to true else if Sender is not “Grape” then set tSwitchGrape to true end doThisThing The switch is as follows, but note that you cannot "set" a variable, only a property. So though the overall syntax that follows is correct, the handler will not compile. on doThisThing tSender switch case tSender is not “Apple” set tSwitchApple to true break case tSender is not “Peach” set tSwitchApple to true break case tSender is not “Grape” set tSwitchApple to true break end switch end doThisThing In other words, the snippet "set tSwitchApple to true" has to be something like: set the tSwitchApple of this stack to "true" or if indeed a variable" put "true" into tSwitchApple Craig Newman on doThisThing tSender if tSender is not “Apple” then set tSwitchApple to true end if if Sender is not “Peach” then set tSwitchPeach to true end if if Sender is not “Grape” then set tSwitchGrape to true end if end doThisThing -Original Message- From: Peter Bogdanoff To: How to use LiveCode Sent: Tue, Aug 4, 2015 5:26 pm Subject: Control structure with "not" Is it possible to convert this to a switch control structure, or otherwise refined somehow? The “not” is what I need, and the setting has to be always “true”: on doThisThing tSender if tSender is not “Apple” then set tSwitchApple to true end if if Sender is not “Peach” then set tSwitchPeach to true end if if Sender is not “Grape” then set tSwitchGrape to true end if end doThisThing Peter Bogdanoff UCLA ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Control structure with "not"
This won’t work for me because ALL the switches always have to be set to true, except for the one related sender. On Aug 4, 2015, at 2:40 PM, Peter Haworth wrote: > You could: > > set tSwitchApple to (tSender is not "Apple") > set tSwitchPeach to (tSender is not "Peach") > set tSwitchGrape to (tSender is not "Grape") > > Slightly different than your code because the switches would be set to > false if the condition isn't met whereas you code doesn't do that. > > On Tue, Aug 4, 2015 at 2:25 PM Peter Bogdanoff wrote: > >> Is it possible to convert this to a switch control structure, or otherwise >> refined somehow? The “not” is what I need, and the setting has to be always >> “true”: >> >> on doThisThing tSender >>if tSender is not “Apple” then >>set tSwitchApple to true >>end if >> >>if Sender is not “Peach” then >>set tSwitchPeach to true >>end if >> >>if Sender is not “Grape” then >>set tSwitchGrape to true >>end if >> end doThisThing >> >> Peter Bogdanoff >> UCLA >> ___ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your >> subscription preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode >> > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Control structure with "not"
You can always use 'switch' without specifying an expression to evaluate as part of the 'switch' line, like so: switch case (tSender is not "Apple") put true into tSwitchApple --break case (tSender is not "Peach") put true into tSwitchPeach --break case (tSender is not "Grape") put true into tSwitchGrape --break end switch Or there's this. It doesn't generate errors but it also doesn't work - the variables are not filled by it: switch tSender case (not "Apple") put true into tSwitchApple --break case (not "Peach") put true into tSwitchPeach --break case (not "Grape") put true into tSwitchGrape --break end switch ("break" is commented to allow same logic flow as your example) Here's another way (that does work) to skin that cat: on doThisThing pSender constant kFruits = "Apple,Peach,Grape" put kFruits into tFruitsA split tFruitsA with comma as set put false into tFruitsA[pSender] end doThisThing I love arrays. And there are probably many other ways to do it. Phil Davis On 8/4/15 2:24 PM, Peter Bogdanoff wrote: Is it possible to convert this to a switch control structure, or otherwise refined somehow? The “not” is what I need, and the setting has to be always “true”: on doThisThing tSender if tSender is not “Apple” then set tSwitchApple to true end if if Sender is not “Peach” then set tSwitchPeach to true end if if Sender is not “Grape” then set tSwitchGrape to true end if end doThisThing Peter Bogdanoff UCLA ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode -- Phil Davis ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Control structure with "not"
Maybe I'm misunderstanding what you want but I think my code does that. For example, let's say tSender is "Apple": set tSwitchApple to (tSender is not "Apple") --> false set tSwitchPeach to (tSender is not "Peach") --> true set tSwitchGrape to (tSender is not "Grape") --> true Looking at your code again, it's unclear as to whether your tSwitchxxx things are variables or custom properties. Using "set" makes me think they are custom properties but then you would need "of " or the script won't compile. If they are variables, then use "put" to put values into them. If they are variables, I'd make the switches into an array and then: repeat for each item rFruit in "Apple,Peach,Grape" put (tSender is not rFruit) into tSwitches[rFruit] end repeat And I really like Phil's "split" solution! On Tue, Aug 4, 2015 at 2:49 PM Peter Bogdanoff wrote: > This won’t work for me because ALL the switches always have to be set to > true, except for the one related sender. > > On Aug 4, 2015, at 2:40 PM, Peter Haworth wrote: > > > You could: > > > > set tSwitchApple to (tSender is not "Apple") > > set tSwitchPeach to (tSender is not "Peach") > > set tSwitchGrape to (tSender is not "Grape") > > > > Slightly different than your code because the switches would be set to > > false if the condition isn't met whereas you code doesn't do that. > > > > On Tue, Aug 4, 2015 at 2:25 PM Peter Bogdanoff wrote: > > > >> Is it possible to convert this to a switch control structure, or > otherwise > >> refined somehow? The “not” is what I need, and the setting has to be > always > >> “true”: > >> > >> on doThisThing tSender > >>if tSender is not “Apple” then > >>set tSwitchApple to true > >>end if > >> > >>if Sender is not “Peach” then > >>set tSwitchPeach to true > >>end if > >> > >>if Sender is not “Grape” then > >>set tSwitchGrape to true > >>end if > >> end doThisThing > >> > >> Peter Bogdanoff > >> UCLA > >> ___ > >> use-livecode mailing list > >> use-livecode@lists.runrev.com > >> Please visit this url to subscribe, unsubscribe and manage your > >> subscription preferences: > >> http://lists.runrev.com/mailman/listinfo/use-livecode > >> > > ___ > > use-livecode mailing list > > use-livecode@lists.runrev.com > > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > > http://lists.runrev.com/mailman/listinfo/use-livecode > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode