Empty fields and controls after testing

Björnke von Gierke bvg at mac.com
Thu Oct 27 07:15:26 EDT 2011


I think one of the problems here is the mixing of not quite compatible metaphors.

HyperCard (and in extension LC which inherited most of those behaviours) uses a data model exactly like a Database. That means all data entry will be permanent, and fields are not data entry points, but data retaining containers.

Now most Database Interfaces work exactly the other way around. They enter constantly changing data that is stored somewhere else into an interface, which is then shown to the user in a unifiedmask or other virtual representation. Often, to edit that data, the user has to go to a specific edit mode, or a completely different data entry UI.

To fake that behaviour in LC, one has to do a few additional steps. There's different approaches, but they will all feel a bit off, because the systems simply do not match up.

I would use a way to store the last query, and then run the whole code that pulls the data from the database. This code would be the same that would run on user interaction to gather data and distributes it into the appropriate places in the LC UI. But instead of (for example) a search result triggering it, it would run on startup or opencard, or whatever is appropriate. That way the display is always correct, and what was saved with the stack in the fields becomes irrelevant.

On 27 Oct 2011, at 00:18, Pete wrote:

> Gotta think about other types of controls too, like option menus, etc.
> 
> Maybe it's just the type of applications I tend to write but I want a lot of
> my stacks to retain their data from last time they were closed and not
> re-initialise them.
> 
> For example, I have a stack that lists a bunch of accounts in a datagrid
> (populated from an SQL db) and users can filter the accounts by account
> type. Then when the user clicks on an account, they get various information
> about it in other controls, plus a second datagrid gets populated with the
> latest transactions in the selected account.
> 
> When the stack is opened, I want the user to see what what displayed to them
> at the time they last closed the stack so I re-populate the accounts
> datagrid based on whatever filters they had in place when the stack was
> closed (in case any new accounts got added, etc), select the accounts
> datagrid row they had selected when the stack was closed, etc, etc.  I guess
> that's still a form of initialisation.
> 
> Most of the time, I only want to initialise controls in my stack to empty or
> some other value when it's designed to insert a new entry into the db.  For
> that type of stack, I initialise the controls to the default value defined
> in the database for the SQL column related to the control, taking into
> account option menu choices, etc.
> 
> 
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
> 
> 
> 
> 
> On Wed, Oct 26, 2011 at 2:43 PM, Ken Ray <kray at sonsothunder.com> wrote:
> 
>> 
>> On Oct 26, 2011, at 11:19 AM, Bob Sneidar wrote:
>> 
>>> Yes, you will need to write your own initialization routine. I do this
>> anyway in all my forms because I read data into the fields, and then
>> validate before writing them back to my storage. I always want to make sure
>> I do not have any random data from a previous edit session making it's way
>> into my database. Usually I have a populate handler that when passed empty
>> for the arguement instead of a string or array, it puts empty into all my
>> fields. Then I just call the populate handler when I open the form,
>> typically in preOpenCard.
>> 
>> 
>> One thing to be careful about - NEVER do this (unless you are 100% sure):
>> 
>> on preOpenCard
>> repeat with x = 1 to the number of fields
>>   put empty into field x
>> end repeat
>> end preOpenCard
>> 
>> It seems reasonable, but what it will do is to empty out your label fields
>> as well, which can be a real PITA to put back again. It's always better
>> (IMHO) to either address the fields you want to clear *directly*, like:
>> 
>> on preOpenCard
>> put "FirstName,LastName,Age" into tFields
>> repeat for each item tField in tFields
>>   put empty into field tField
>> end repeat
>> end preOpenCard
>> 
>> OR, set some kind of custom property on the fields you want to clear (or
>> protect), or at least make sure you walk carefully on fields that have their
>> lockText turned on (which is what label fields have by default), like:
>> 
>> on preOpenCard
>> repeat with x = 1 to the number of fields
>>   if the lockText of field x is false then
>>     if the short name of field x is not among the items of
>> "PrefilledField, DefaultCity" then
>>       put empty into field x
>>     end if
>>   end if
>> end repeat
>> end preOpenCard
>> 
>> Just my 2 cents…
>> 
>> Ken Ray
>> Sons of Thunder Software, Inc.
>> Email: kray at sonsothunder.com
>> Web Site: http://www.sonsothunder.com/
>> 
>> _______________________________________________
>> 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


-- 
Watch live presentations every Saturday:
http://livecode.tv

Use an alternative Dictionary viewer:
http://bjoernke.com/bvgdocu/

Chat with other RunRev developers:
http://bjoernke.com/chatrev/





More information about the Use-livecode mailing list