[Gambas-user] Safety for collections

Fabien Bodard gambas.fr at gmail.com
Wed Aug 23 20:05:25 CEST 2023


I don't if it is what you mean... for the modified flag it can be in a
parallel collection that handle a boolean.

Le mar. 22 août 2023 à 18:55, T Lee Davidson <t.lee.davidson at gmail.com> a
écrit :

> On 8/22/23 07:08, BB wrote:
> > There is probably a simple way to do this, damned if I can see how.
> >
> > I have a collection of things (datObjects) that have a property
> (ObjectName::string) that in UML terms are Unique and ID. What I
> > am trying to do is prevent the _replacement_ of an object in the
> collection if the ObjectName is already there. Better still,
> > I'd like to warn the user when they enter the ObjectName that it already
> exists.
> >
> > The input form has a TextBox for the ObjectName and a "save" button. The
> latter updates the collection, whose key is the
> > ObjectName, either adding or amending the item in the collection. So I
> kind of need to do this:
> >
> > 1) Are they really trying to add a new item or update an existing one?
> >
> > If adding then prevent them from overwriting one with the same
> ObjectName, otherwise if amending then only allow changes to the
> > other data and not the ObjectName.
> >
> > 2) Then update the collection accordingly.
> >
> > Is that clear? It isn't to me. Any input would really be appreciated.
> >
> > b
> >
> > p.s. I am trying to avoid having separate Add and Update buttons for
> reasons.
>
> Perhaps use a global boolean as a semaphore to indicate if the ObjectName
> field has been changed (using, of course, the
> TextBox's Change event).
>
> Upon clicking "Save", if the name has been changed, then logic would say
> the user is attempting to Add a new name. So then check
> to see if the new name already exists and, if so, pop up a form listing
> similar, existing names so they can create a name that
> does not exist; or simply let them enter a new name and click a "Check"
> button which would repopulate the form.
>
> The form popped up should have a "Cancel" button that would set the
> semaphore to False. A successful save should also reset the
> semaphore.
>
>
> --
> Lee
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>


-- 
Fabien Bodard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230823/1166509a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: democollection-0.0.1.tar.gz
Type: application/gzip
Size: 12190 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230823/1166509a/attachment.gz>


More information about the User mailing list