Control structure with "not"

Peter Haworth pete at lcsql.com
Tue Aug 4 18:32:24 EDT 2015


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 <objectreference>" 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 <bogdanoff at me.com> 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 <pete at lcsql.com> 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 <bogdanoff at me.com> 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 at 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 at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list