Managing Images in the Image Control

Peter M. Brigham pmbrig at gmail.com
Tue Dec 24 16:41:07 EST 2013


I looooooove custom properties. One of the truly inspired additions to the old Hypercard framework. You can store anything in a custom property, a simple value, a string, htmlText, an image, an array, even a whole stack, and then access it whenever you need to. If you get comfortable with customprops you will cut way down on your use of global variables, which have the disadvantage of cluttering up the variable space and getting overwritten by accident unless you use a proprietary naming convention.

I use them for storing user preferences, I use them to store images associated with various things, for lists that need to be maintained between launches. I use them to store platform-specific stuff like help text -- set up a closefield handler in your help text field that takes the text of the field and replaces things like "command-click" with "control-click" and stores the result as "the winHelp of this stack", so you never have to write two help texts again. Etc., etc. Once you get familiar with customprops you'll keep discovering more and more ways to use them.

It's definitely worth the time to get comfortable with custom properties.

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig


On Dec 24, 2013, at 1:29 PM, Paul Hibbert wrote:

> Hi Vaughn,
> 
> Not wishing to butt in, I've just sent this reply in case Klaus is away from his computer for a while, he'll probably have some better insights, but this should get you going.
> 
> The simplest lesson is: http://lessons.runrev.com/s/lessons/m/4603/l/44049-livecode-properties
> 
> Scroll down to the Custom Properties section near the bottom of the lesson.
> 
> Another lesson here: http://lessons.runrev.com/s/lessons/m/4071/l/13158-what-are-the-alternatives-to-using-global-variables
> Another: http://lessons.runrev.com/s/lessons/m/4071/l/17375-how-do-i-save-custom-properties-in-a-standalone-application
> A little more advanced: http://lessons.runrev.com/s/lessons/m/4071/l/11900-how-do-i-define-my-own-properties-for-an-object
> 
> Custom Properties are extremely useful at times, you can think of them as a container, a bit like a global variable because they can be accessed from anywhere in your app, but they are also more versatile as you can store data that doesn't disappear between launches in saved stacks, or you can store data as you build you app in the IDE that is accessible in your final standalone. Custom properties work extremely well alongside behaviour scripts too.
> 
> There are a few simple rules to remember with custom properties, you can't simply put a value into a custom prop, you have to "set" the custom property in one go. e.g.:
> 
> put "10" into the cNumber of this stack --< doesn't work
> set the cNumber of this stack to "10" --< does work
> 
> You can't modify part of a custom prop, you need to read out the whole value, modify it and then replace it. e.g.:
> 
> set line 2 of the cNumber of this stack to "20" --< doesn't work
> 
> get the cNumber of this stack       --/ Read the Custom Prop
> put "20" into line 2 of it          --| Modify the values
> set the cNumber of this stack to it --\ Then replace the values - does work
> 
> Most LC programmers use a "c" (for custom) or "u" (for user) prefix to denote a custom property, but like most of LC you are free to work your own way.
> 
> Once the penny drops you will find Custom Properties very useful, but just ask about anything you are unsure of.
> 
> Have fun.
> 
> Paul
> 
> 
> On 2013-12-24, at 9:48 AM, Vaughn Clement <vclement at gmail.com> wrote:
> 
>> Hi Klaus
>> 
>> Being new to LC I have not created a custom property yet. I reviewed the
>> properties in the dictionary but I was overwhelmed by the number of choices
>> of which none seem to fit? Can you point me in the right direction (lesson
>> or reference) where this might be used?
>> 
>> Thank you
>> 
>> Vaughn Clement
>> 
>> Apps by Vaughn Clement (Support)
>> *http://www.appsbyvaughnclement.com/tools/home-page/
>> <http://www.appsbyvaughnclement.com/tools/home-page/>*
>> Skype: vaughn.clement
>> https://secure.join.me/appsbyvclement
>> FaceTime: vclement at gmail.com
>> LogMeIn also avaialble
>> Call on "ooVoo" at address:  vaughnclement or 9282549062
>> Ph. 928-254-9062
>> Cloud Hosting Registration Web Site:
>> https://my.oditech.com/cart.php?a=add&pid=41
>> 
>> 
>> On Tue, Dec 24, 2013 at 10:07 AM, Klaus major-k <klaus at major-k.de> wrote:
>> 
>>> Hi Vaughn,
>>> 
>>> Am 24.12.2013 um 18:03 schrieb Vaughn Clement <vclement at gmail.com>:
>>> 
>>>> Hi Klaus
>>>> 
>>>> I will try that next. I was really lost as a new user trying to find a
>>> way
>>>> to store the images.
>>> 
>>> Okie Dokie :-)
>>> 
>>> to store use this syntax:
>>> ...
>>> set the cStoredCardImage of this cd to the text of last img
>>> delete last img
>>> ...
>>> 
>>>> Thank you
>>> 
>>> My pleasure!
>>> 
>>> Happy holidays! :-)
>>> 
>>>> Vaughn Clement
>>> 
>>> Best
>>> 
>>> Klaus
>>> 
>>> --
>>> Klaus Major
>>> http://www.major-k.de
>>> klaus at major-k.de
>>> 
>>> 
>>> _______________________________________________
>>> 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