Help how to make such widget

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

Help how to make such widget

Post by terryho » Thu Jan 18, 2018 6:27 pm

Hi all,

    I want to make a widget to setup database information, but i'm stuck  on how  to put script in the opening of stack.

    I have search on the newsgroup, which said that widget cannot use on that purpose, can anyone suggest method to make it.

Regards

Terry Ho

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Help how to make such widget

Post by Mark » Wed Mar 28, 2018 9:50 pm

Why do you want to make a widget? I always write a relatively simple script to set up my database. It doesn't need a specific GUI and doesn't need direct access to the API of the OS. I see no reason to use LCB, but if you do please enlighten me.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

Re: Help how to make such widget

Post by terryho » Sun Apr 29, 2018 4:59 pm

Hi Mark,

Thanks your reply.

I want to make a database widget, which help the beginner to work with database in livecode.

Once drop the "dbconnect" widget, which has the follow :

Connection type : local/ remote
Db type: sqlite/mysql/odbc/etc
Server ip:
Db path:
Login :
Password:

User just input the above, can easy to make db connect, also reduce input error.

If have the above information, the question is how to put such statement, in the opening of script or opening of the card.

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Help how to make such widget

Post by bwmilby » Mon Apr 30, 2018 3:59 pm

Sounds much more like the job for a grouped control than a widget. I could see it in a stack where you experiment with databases, but once you are building an actual app you will need to code the connection. The control could generate the connection code for use in script though.

I don’t really understand what you are asking about the opening stack though. You need to save the connection information somewhere and then load it to use. But unless you are building a generic DB browser, your stack/app will probably have a limited set of DB connections required.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

Re: Help how to make such widget

Post by terryho » Tue May 01, 2018 3:21 am

I use the following code, in the pre opening of the stack to make it connect with the DB, if for desktop remote db, it will be more parameter, if have a widget, then it will be more easy to setup the db in each db application. Especially for the beginner

if the environment is mobile then
put specialFolderPath("documents") & "/" & tdbname into tDatabasePath
if there is not a file tDatabasePath then
put specialFolderPath("engine") & "/" & tdbname into eDatabasePath
put URL ("binfile:" & eDatabasePath) into URL ("binfile:" & tDatabasePath) 
end if

put revOpenDatabase("sqlite", tDatabasePath, , , , ) into gDBID
set the pdbID of me to gDBID
else
set itemDel to "/"
put item 1 to -2 of (the effective fileName of this stack) into tCurrentPath
put tCurrentpath & "/" & tdbname into tDatabasePath
put revOpenDatabase("sqlite", tDatabasePath, , , , ) into gDBID
set the pdbID of me to gDBID
end if

Also I want to make a set of DB widget, the first one is the connection, which make a standard point the get the connection ID, then it will be table creation widget, browse widget, update form widget and etc. Without the way to put the code in the opening of stack or card. It can not make such things happen. I want to make LC will be more easy to develop db apps in both desktop and mobile.

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Help how to make such widget

Post by bwmilby » Tue May 01, 2018 4:06 am

I still don’t get the desire to use a LCB widget. I’m not even sure it is possible to easily make a DB connection from there.

What you are describing sounds much more like a LCS library. If you need UI, then a stack. If not, then a script only stack would work.

In either case, I suggest that you build what you want as a simple stack first.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

Re: Help how to make such widget

Post by terryho » Sat May 05, 2018 10:52 am

Attach is lcb, which make some of the user interface, but I can not make some function, due to my lack of some knowledge and livecode library. Please advise.
Attachments
DbSetup.lcb.zip
(1.93 KiB) Downloaded 246 times

Post Reply

Return to “LiveCode Builder”