Upper/Lower case issue

Nonsanity form at nonsanity.com
Tue Jul 5 12:53:16 EDT 2011


I see what you are doing there Pete, and why you went the way you did. It
what you've got will work and is a decent solution to the problem as you
defined it. The loop does the mapping that you can't do with the engine.

the problem is the fact that the "%m" or "%M" is coming from an outside
source and needs to be mapped to the correct button. By passing the name of
each button in turn through a variable, the case sensitive comparison can be
done. Without that, setting the hilitedButton of the group to "%m" probably
won't give the right results, depending on the order in which the buttons
are arranged.

The biggest downside to this is if, in the future, you ever need to access
one of those buttons elsewhere in the code. If so, it would HAVE to be done
by ID instead of name. Not a show stopper, but a bit ugly. And if you never
need to... it's moot.

But even that one problem can be solved by setting a custom property on each
button to the "%m" or "%M" you currently use as the name, and give them case
insensitive unique names you can use elsewhere in your application. Your
script would be almost unchanged... Just change "the short name of" to "the
customName of" in your script (if customName is the property you fill with
the "%m" etc).

 ~ Chris Innanen
 ~ Nonsanity


On Sat, Jul 2, 2011 at 12:43 PM, Pete <pete at mollysrevenge.com> wrote:

> Hi Craig,
> Just to be clear, the button names are not identical - one is upper case
> and
> one is lower case.  In its wisdom, LC treats them as identical because they
> are object names but if those string were not object names, they would not
> be treated as identical if casesensitive was true.
>
> Here's what I'm trying to do.
>
> The names of the buttons are strings that define elements of date formats.
>  For example, %m means zero suppressed month number and %M means 2-digit
> month numbers with leading zero, %d means zero suppressed day number, %D
> means 2 digit day number, etc.  This is a very common convention for
> defining date strings.
>
> Since those are pretty cryptic strings, I use the button labels to show a
> more meaningful description to the user and then store the names of the
> buttons (%m, %D, etc) in a date format string in my preferences file.  That
> way, I can pass the date definition string directly to my date formatting
> handler.  Next time the preferences card is opened, I need to get the
> settings from the prefs file and set the appropriate buttons, and that's
> where the problem arose.
>
> Here's the code I used to get round the problem.
>
>   *    *
>
> *private command setButtonHilite pgroup, pbutton*
> *
>
>   set the casesensitive to true
>
>   repeat with count=1 to the number of buttons in group pgroup
>
>      put the short name of button count of group pgroup into myName
>
>      if myName is pbutton then
>
>         set the hilitedButton of group pgroup to count
>
>         exit repeat
>
>      end if
>
>   end repeat
>
> end setButtonHilite
>
>
> There are only 2-4 buttons in each group I need to process this way so
> there's no performance hit. I suppose I could have used a custom property
> to
> do this but I'd already gone down the path of using the button name before
> I
> discovered the casesensitive issue so opted to stick with that approach.
>  Plus I would have needed a similar command to locate the button with the
> correct custom property.
>
>
> Hope that explains the situation
>
>
> *
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
>
>
>
>
> On Fri, Jul 1, 2011 at 10:38 PM, <dunbarx at aol.com> wrote:
>
> > Pete.
> >
> >
> > In the old HC days, before there was a name AND a label, I might have
> > understood that you might have a valid reason to use identical names. You
> > are aware that these two properties exist, and still have your reasons.
> Can
> > you say briefly what they are?
> >
> >  I know you said they were too complicated, but just a one or two liner?
> >
> >
> > Craig Newman
> >
> >
> >
> >
> > -----Original Message-----
> > From: Mark Wieder <mwieder at ahsoftware.net>
> > To: How to use LiveCode <use-livecode at lists.runrev.com>
> > Sent: Fri, Jul 1, 2011 8:56 pm
> > Subject: Re: Upper/Lower case issue
> >
> >
> > Pete-
> >
> > Friday, July 1, 2011, 4:41:16 PM, you wrote:
> >
> > > That's OK Mark, I agree with what you said 99.99999% of the time, it's
> > just
> > > that there is a valid reason for what I'm doing in this particular
> > instance.
> >
> > It seems like you found a way out of your predicament, but I'm still
> > with Mark on this. If you think you need to give the same name to two
> > buttons there's another way of getting the result you're looking for.
> >
> > --
> > -Mark Wieder
> >  mwieder at ahsoftware.net
> >
> >
> > _______________________________________________
> > 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