Xojo Like FileMaker...

So, I use FileMaker and Xojo. In a ton of cases, I love how FileMaker layouts are connected to a record set. I’d like to have that functionality in Xojo, but a ton of folks say that the DataControl isn’t ideal. So I’d like to create my own version of the functionality.

My plan was subclass fields and listbox to add properties for table and field. Then I’d add a recordset to the Window/Page.

Once I set the recordset, how can I tell all the fields and subclasses to update themselves?

don’t forget a VERY important distinction here… Filemaker is an application, while XOJO is a programming environment

What appears magical in Filemaker, required a huge amount of effort by the developers using whatever programming environment they chose.

So don’t expect that it will be magic. It will require that you have an understanding of how databases work (including SQL), how the XOJO GUI elements work, and then patiently design a process that marries the two together in such a manner as to do what you desire.

Your approach will not only require the above knowledge, but also how various events interact. It is not possible to give a direct answer to your question based solely on the information provided.

Thanks Dave,

I did ask a specific question. If I subclass a field and then add many fields to the window, is there a way to trigger an event on all of them?

It’s not magic. Just click a button to build a recordset, and fill in the fields. I was just hoping to not have to run a method for EACH field on the window, but rather somehow tell all fields to update themselves based on the recordset.

FileMaker is a programming environment. It can do just about anything Xojo can do, but it’s primarily designed around tables and records.

You might want to look at interfaces.
DataNotificationReceiver or ActionNotificationReceivermight be along that line.

In the examples look at Design Patterns -> Observer

Thanks Jim & Markus!

It looks like I can loop thru the controls on the window and assign them to and observer. That freaking rocks.

This is sort of true, but also somewhat misleading. There’s a lot of overlap between FileMaker and Xojo in terms of features. I use both products extensively, and I often find myself asking “Hmm, I wonder which product would be better” and it’s often not a clear answer.

There is also a Design patterns webinar you should probably see.

More at https://www.xojo.com/support/webinar.php

That last time I used FileMaker was in the mid-late 90s so my memory is hazy…

But what I recall as the best thing was that you could put a bunch of controls in a container as we would in a window or container control and link them to DB records. These these then could be displayed as a smooth scrolling list on screen or be printed. You could define if a control on the container should be printable or not as well as some page fields for printing…

At first glance one would think on could define an reusable APIs with events for loading etc and by subclassing controls to be used in such containers etc …

And yes on OS X it is easy to do… In fact I could create such that thing fairly easily on OS X, though there would be a lot of little details to work out.

In point of fact a good while back I quickly put together some proof of concept code to make sure it could be visually acceptable. See:
Dropbox mp4 link

I ran that old code shown above just now on 10.9… In 10.10 the “vibrancy” of the window should show through (assuming 10.10 does not cause other issues)

If I only needed things to work on OS X that proof of concept would have had me very happy… but I needed it on Windows too…

When I tried to do the same things on Windows (which is why you see all those settings in the video) there were so many visual glitches. I got tired of trying to work around all of them… I came close bitty never got all teh way there before I ran out of time. I’m not even sure if it is possible to make it work without visual glitches with Xojo as it is… I suspect as long as Xojo is using Win32 APIs things like this XPlatform became a very difficult

If someone has done it on Windows I would REALLY like to know how they got it to work!

If I ever have a lot of time and more patience I’ll see if I can figure a way to get it to work OK on Windows and generalize the code.

That said a control to do this should be part of Xojo itself…

Unlike Filemaker, I would have coded it to just have events to load and save data to and from records so the data source could be anything. Binding controls to DB fields is just not flexible enough for all cases and it lis easy easy enough to code ourselves anyway.

  • Karen

[quote=145213:@Karen Atkocius]See:
Dropbox mp4 link

  • Karen[/quote]

O.M.G!

KAREN IS AN AGENT OF S.H.I.E.L.D.!

:wink:

P.S impressive demo!

very cool demo Karen

[quote=145258:@Markus Winter]KAREN IS AN AGENT OF S.H.I.E.L.D.!

[/quote]

Quiet!!! It’s a secret! :wink:

Seriously though on OSX that proof of concept was trivial to do.

BTW was my memory of FileMaker functionality from the mid 90’s right?

Still cool. Write an xDev article about it?!

i want to do something similar

I followed the pattern in the Observer example in order to tell my fields used for the database to update with one call. It works great.

Both fields are subclassed TextField controls called dbTextField. The dbTextField subclass has an interface called “ObserverInterface”. The RegisterObserver method passes in a ObserverInterface to add the controls to an array.

I can Register the fields controls as Observers by specifically registering them. Works perfectly.

RegisterObserver( NameFirstTextField ) RegisterObserver( NameLastTextField )

However, I’d like to just loop thru all the controls and have the dbTextfields be registered, but it returns a complile error on “RegisterObserver” stating the “Parameters are not compatible with this function” using the code below.

[code] dim theControl as control
For i As Integer = 0 To window1.ControlCount
theControl = Window1.Control( i )

select case theControl
case IsA dbTextField
  RegisterObserver( theControl )
end select

Next[/code]

Is there a way I can get the loop to work? I’d rather not have to hard code the registration of the dbTextFields.

Here’s a link to my sample project. If you run it, you can see what I explained above. If you comment out the for loop and uncomment out the two RegisterObserver statements, it works fine…

[quote=145213:@Karen Atkocius]When I tried to do the same things on Windows (which is why you see all those settings in the video) there were so many visual glitches. I got tired of trying to work around all of them… I came close bitty never got all teh way there before I ran out of time. I’m not even sure if it is possible to make it work without visual glitches with Xojo as it is… I suspect as long as Xojo is using Win32 APIs things like this XPlatform became a very difficult

If someone has done it on Windows I would REALLY like to know how they got it to work![/quote]
Why not put the source code up as a community project and let the Windows specialists have a crack at it?

[quote=145371:@Hal Gumbert]I followed the pattern in the Observer example in order to tell my fields used for the database to update with one call. It works great.

Both fields are subclassed TextField controls called dbTextField. The dbTextField subclass has an interface called “ObserverInterface”. The RegisterObserver method passes in a ObserverInterface to add the controls to an array.

I can Register the fields controls as Observers by specifically registering them. Works perfectly.

RegisterObserver( NameFirstTextField ) RegisterObserver( NameLastTextField )

However, I’d like to just loop thru all the controls and have the dbTextfields be registered, but it returns a complile error on “RegisterObserver” stating the “Parameters are not compatible with this function” using the code below.

[code] dim theControl as control
For i As Integer = 0 To window1.ControlCount
theControl = Window1.Control( i )

select case theControl
case IsA dbTextField
  RegisterObserver( theControl )
end select

Next[/code]

Is there a way I can get the loop to work? I’d rather not have to hard code the registration of the dbTextFields.

Here’s a link to my sample project. If you run it, you can see what I explained above. If you comment out the for loop and uncomment out the two RegisterObserver statements, it works fine…[/quote]
Hi Hal, The issue here is that the Control class does not implement the ObserverInterface, only your dbTextfield Class does. Because of this, a generic Control cannot be passed to the RegisterObserver method. To make this work, you simply have to cast “theControl” to a dbTextField once you have ensured that it is one with your select case, and pass that to the RegisterObserver method.
If you change the line

RegisterObserver( theControl )

to

RegisterObserver( dbTextField(theControl) )

it will work properly.

@Jason King FTW! I just went through a very similar set of circumstances and the solution doesn’t fall into the “Obvious” category :).

Thanks Jason! It did work perfectly. I need a to take a class on classes. :slight_smile:

Agreed, some of the compiler errors (this one especially) could definitely be improved so that what is wrong is more obvious.

Glad I could help!