Advice Needed

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Advice Needed

Post by Simon » Thu Oct 30, 2014 5:14 am

This should contain most of the operations you want.
http://livecodeshare.runrev.com/stack/773/Book-Library

Just say if you need more.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Advice Needed

Post by jacque » Thu Oct 30, 2014 7:51 pm

sadarahu wrote:
There aren't examples because this is part of being a programmer.
this sounds like a poor joke

I worked with other tools and there are plenty of grid/form examples, so saying "this is the way it is because you're programmer" makes no sense to me and is very discouraging.
I'm sure Simon didn't mean it that way, he's very helpful here in the forums and a nice guy who would never want to discourage you. I think what he meant was that there is no automatic way to link up a few controls and have them act like a dedicated database. You need to program that part. There are lots of database-related commands in the dictionary that will allow you to do what you want, but you need to write the scripts that use them. Perhaps the best way to proceed would be for you to lay out a card with the controls you will need to retrieve and display database data. Then start scripting each step -- first open a database, next retrieve data from it (which may include getting responses from the user first, depending on what you're doing.) Then display that data in fields. If you get stuck at any step, folks here can help.

There is no "form" per se in LC. You can drag controls to a card and that's a kind of form, in a way. You can group them to behave like a single unit, or put them on a different card, or even in a different stack. You can add a "Select" button to the group if you need one. But in LC a "form" is just a group of controls. The datagrid object is using that concept when it makes a distinction between a list ("grid") and a group of controls that appear in each cell ("form").

Some of your other questions:

There is a tab button object in the tool palette. That is how you make tabs. But the behavior needs to be scripted; you can either change cards when a tab is clicked, or show/hide groups, or do whatever other action you need. You do not need a third-party add-on to make a tabbed interface.

You can create multi-language apps by storing menus and labels for each language in custom properties. Again, you need to script all this. When the user changes languages, your scripts will loop through all objects and change their labels to the chosen language. I'd put this off until you're more familiar with how LC works, it will be easier to implement after you app is written in a single language first.

It is always possible to develop off-line. Except for initial installation of a new version, no online connection is necessary. Of course, if your app needs to retrieve server data then you'll need a connection.

LC can manage screen sizes and resolutions automatically. You will need to include a few lines of script to tell it to do that. Ask when you get that far.

Finally, chin up. The LC paradigm is much different from what you're probably used to and it will take a few weeks to get your bearings. It's sometimes harder for those coming from other languages because of prior expectations about what things mean and how they work. But it will fall into place pretty quickly, just try a few things and suddenly everything will become clear.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sadarahu
Posts: 12
Joined: Sun Oct 12, 2014 8:23 pm

Re: Advice Needed

Post by sadarahu » Fri Nov 07, 2014 6:25 am

Jacqueline!
Thank you for your reply, at least somebody has bothered to answer most of my questions in clean manner. The only thing that kinda bothers me and it is also a mystery question how come there are almost no examples. The examples that exist are by far less important than the ones I requested. By saying try to do this and that you probably do not understand that I have no idea where to start to grasp the concept. Instead of pulling my hair and asking million questions taking your precious time it would be much easier to create 2-3 typical fully functional database apps and allow users to study them. Placing examples which are completely out of the context or which apply to completely different scenarios (at least for beginners) make not much sense.

When you install MS-ACCESS for example you get few simple Apps which show famous Northwind database and how to operate one the data. I would expect something similar. It would make my like so much easier. So farm I'm dealing with this thread for a month and haven't gotten really far.

I just noticed the other post with the example (by Simon). Thank you for your time and doing this. I have seen this example, it is helpful but it does not show me the typical data edit scenario. Also when I opened this App there is a separate window ".Back Scripts"
Simon - could you explain its role ?



Now to the App ->
CRUD EXAMPLE
When I click UPDATE ROW IN dB button the app pops up a message but nothing else happens. Another words I would like to see a little bit different functionality.
1. user selects record (by LongPress) or click
2. form with 2 fields (Handle, entry) pops up
3. user changes data and clicks SAVE (or update) button
4. updated record is saved and successful message is displayed
5. user is returned to grid

this would be for me like a basic of the basic....
and the most common scenario. This is also how I created app in B4A.
I'm not interested (at least at this moment in so called "Edit In Place" where user edits data while being still in a grid).
This is a desktop App and I also wonder how the buttons are transformed when this App is generated for mobile dev ?

BOOK LIBRARY
This one is much better. I will study this and will probably come back with some questions. For now just one question: how can I see this App in action on a mobile device. shall I just generate it and run it in Android Emulator and I need to change some settings ? It seems like the GRID and FORM(fields) are on the same screen(card) so I'm sure this will not fit on a small mobile phone (for example). ?
This App is however very close to what I asked for, thank you again....you certainly improved my mood now :D


Arthur

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Advice Needed

Post by jacque » Fri Nov 07, 2014 9:07 pm

The problem here is that you're asking a very broad question that has no specific answer. There a many ways to write a database app, and how you do it depends on the kind and amount of data you'll be working with. There are lots of ways to do every task in LiveCode, which is why the examples you've read usually only deal with discreet actions rather than whole apps. As the developer, it's up to you how you want to combine those actions into a working app.

For example, you can create a database where each card in the stack is a single record and then use the stack structure itself to navigate the data by going from one card to another. Frequently the first card of the stack is an index where clicking a record takes you to that card. This method stores the data directly in the stack in a single file. It's the easiest way to write a database because most of the work is done by the engine, but the disadvantage is that updating this kind of app is difficult. It's better to separate the data from the display structure, but for a beginning project it's simple.

Alternately you can create a database by storing all the data in text files. LC is great with text files, it's very fast and optimized for text, and if all you need is a flat database then this works very well. Your app will load the file data into memory and work with it in scripts, putting the relevant content into fields as needed. Saving changes is a simple matter of saving to a file, which is easy. For flat databases with less than 10,000 records or so, it works great.

Another way is to use a real database and send it SQL commands. This method takes advantage of all the power of a relational database. If you are comfortable with SQL then you'll be at home with this method, though the setup and syntax you'll need to use in your scripts will be more complex.

For displaying data, the datagrid is the most complex object in LC. It is actually not a native control, it is a collection of fields and other scripted objects, written by one of the community's advanced users. I usually recommend avoiding datagrids until you are more comfortable with the basics of scripting, the message hierarchy, and other LC concepts. You can always convert to a datagrid later if you want to.

So to begin -- what type of database do you want to create? Regardless of which method you choose, the first step is to place controls on a card that represent the layout you want to display. The second step is to script them to work together. Will your data show up in a single field as a list? Then you need a list field, probably with tabstops set. Do you want a detailed display with one field for each item of info about each record? Then you might create a card with a field for each data item (a title field, a description field, an ID number field, whatever) and you will be loading data into those fields on demand. That's what this one does: http://www.hyperactivesw.com/solutions_ ... y_pro.html

So let's start with what you need to do. There are likely some examples out there but I'm not aware of where they are. Maybe someone else knows and can point you to them.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sadarahu
Posts: 12
Joined: Sun Oct 12, 2014 8:23 pm

Re: Advice Needed

Post by sadarahu » Fri Nov 14, 2014 6:52 am

OK, I think I'm getting really tired ox explaining. I stated what I'm looking for and I've also posted a simple table structure. I said (I'm not interested in creating database, but accessing and modifying existing one),....etc... I provided suggestions etc. so it would be good to read this thread carefully before answering. I do not ask broad but rather very specific question here. I'm also not interested (at this moment) in web Apps but mobile (phone) apps only.
How come while using other tools I could find many sample Apps to play with but with LC there are almost none ? Is it really so hard to understand what I'm looking for ? ugughghgh .....frustrated and ready to give up :-(
The bottom line is that LC (as a whole) is not really ready or helpful to create mobile database Apps. Why ? not enough learning resources :-(
The fact that some people did something productive does not mean that new user finds LC very attractive. Any tool or language without proper documentation, resources and support will die sooner or later.


Arthur

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Advice Needed

Post by jacque » Fri Nov 14, 2014 8:20 pm

Maybe this will help:

http://lessons.runrev.com/s/lessons/tags?tag=database

The problem here is that there are so many ways to do things in LC. It's a wealth of choices. You are provided with the words, but you have to write your own novel.

Here's some more:
http://samples.on-rev.com/database.irev
http://livecode.byu.edu/database/dbmanagementinrev.php
http://livecode.byu.edu/database/dbaccessinrev.php
http://stackoverflow.com/questions/1744 ... h-livecode
http://www.troz.net/rev/index.irev?cate ... ity#stacks -- scroll down to SQL Test

I found these with a google search for "livecode database".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Advice Needed

Post by AxWald » Sat Nov 15, 2014 8:52 pm

Sadarahu,

reading all of this thread I seem to get a feeling what you're after. Plz excuse if I should be wrong, and ignore my post then.

From your usage of the term "forms" I assume a background in MS Access, or similar. The kind of database front ends that shows tables, helps you creating queries, setting up a user interface using forms, and output the results using reports.

If you want such, there's nothing even remotely reaching MS Access. Sorry, but that is how it is. And all we can do is hoping that MS will improve this one unique program of theirs to be usable on other platforms. I did some tries yet, creating Access front ends that can be used on a (not-MS) tablet using RDP, not perfect yet, but I'm still exploring.
For fast-coded, complex DB-UI's there's not much else that I know of.

Nevertheless, it can be done in LC, too. Even in the old days of HyperCard, it was possible to set up a given set of cards to emulate "forms", "reports" and such. Just not as easy as in Access ...

At the current day, I use LC heavily in my professional database work. For instance, to feed a web shop with runtime-accurate sales data (prices and inventories), doing a rather sophisticated login-checking, and collect the sales, to write it to a cache database (SQLite). This from a standalone running as service on a MS 2003 R2 Server. Done as a socket server.
Additionally, on the same server is running another LC standalone using the AT mechanism (like cronjobs) to regularly import/ modify incoming new data, write them to the cache database, as well to the real database (a web-MySQL now).
Here the great connectivity of LC comes to pass, as well as the awesome features in string handling - creating even very sophisticated SQL statements in LC is a quite easy.

What lacks, and this may be what you're after, is a way to represent the data once you got them. Here you're on your own, and the data grid isn't exactly what I'd regard a big help. For me, it's a q&d hack, it does what it's meant to do, but it's far from being a real help.

You may need to code your own front-end yourself, or use another program for it. I still use Access for the end-user front-end part (nearly all my customers run Windows), just because it knows how to do it already. And I fear, adapting this possibilities would be ways too expensive, and by far not enough sought after to justify it, for LC.

There's some real database "professionals" here, making me blush each time they show their knowledge. Maybe, if we push hard enough, and offer our measly help, there may be a way to at least imitate Access' report making possibilities?
I'd be with you, and I don't doubt we'd get help from the awesome community - just, it's a very remote area for LC. We should be aware of this.

Is there any idea how to set up a "report generator"?

Have a good time!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

sadarahu
Posts: 12
Joined: Sun Oct 12, 2014 8:23 pm

Re: Advice Needed

Post by sadarahu » Sun Nov 16, 2014 3:20 am

I do not use Access (and last time I used it it was years ago). As far as creating grids/forms just to give one an example I used several tools in the past: Code Charge Studio, Scriptcase (for the web), then CLARION and WinDev for desktop Apps. For mobile Apps I used Basic4Android (and I'm happy to hear they just released Basic4iPhone), which probably will be better fit for me. There are tons of examples, the forum is much more active and helpful. Most of all it is very well documented. The only reason I turned out into LC was the ability to create a multiplatform apps, although I'm not interested in web app or desktop apps (I have enough tools and knowledge to make those). I'm only interested in mobile (at the moment). Because of this experience I know what is possible and how much time it takes and I know what can be done. Therefore I'm surprised that LC claims it is so well suitable for database type Apps while it is not. Yes it seems that everything can be done in LC however the question is at what expense (of time). I'm not looking for a tool that requires tedious coding of every single element. My client/user doesn't really care what I used, they just care for the result.
So far all samples (I've seen) were made (correct me if I'm wrong) for the web/desktop not for mobile.
I would like to see a 2 separate objects in the toolbox. GRID and FORM. I simply bring the grid onto the card, setup connection, setup recordset and display data in the grid. Possible play with settings (like sorting, resizing, filtering), but doing this as an event handler is OK as well. When creating a form I would love to see the FORM object to be placed on the card then placing form fields (controls) will make up a form complete. Event handler (i.e like OnButtonClick) would take care of what needs to be done with the data whhen the button is clicked.
It seems natural and simple although I do not see such functionality or I do not know how to do it. At this moment the most popular and standard scenario for data editing is very confusing and (non standard). Using workarounds does not fit the bill here :-(


Art

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Advice Needed

Post by jacque » Sun Nov 16, 2014 6:45 am

It sounds like you're looking for something more automated than LC. You do have to get your hands dirty with the details, even though LiveCode is a much higher level language than most others. There are no "form" objects per se; the card is your canvas and you lay out your own. Just start dragging fields or buttons from the tool palette onto the card. That's your form. If you use standard editable fields, they are already set up for typing, you don't need the popup field you mentioned. You'd script a button that retrieves data from the database and puts it into the fields. You'd script another button that takes the (presumably user-edited) field content and sends it back to the database. That's the basics.

While the examples I linked to were mostly written for desktop deployment, almost all of it will run on mobile too. That's the advantage of LC. Mobile apps do have a few different requirements, and iOS and Android differ between each other as well, so in those cases you do need to use the mobile-specific features LC offers. But the bulk of the code will run anywhere, so you won't see many examples labelled specifically "mobile". It's all the same stuff.

Everything you want to do is possible, but you do need to script each piece. Most of us don't find that particularly tedious but it may be more than you're up for. While I disagree that LC isn't suitable for database work, since we have so many people here who do just that, developers differ in how much detail they want to be involved with so there may be something else that would be a better fit.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: Advice Needed

Post by phaworth » Mon Nov 17, 2014 4:11 am

If you can wait a month or so, my upcoming SQLMagic product will do what you're looking for. No scripts, no SQL, just drag/drop controls (including datagrids), set a couple of properties - Done.
Pete
www.lcsql.com

Post Reply

Return to “Databases”