View script | License | Download documentation as: HTML or editable |
Download script | History | Other scripts by: btiffin |
[0.054] 19.16k
Documentation for: rebdbgui.rUsage document for %rebdbgui.r1. Introduction to %rebdbgui.rrebdbgui.r is an introduction to the ease of gui creation with RebGUI and the ease at fetching and updated data in a RebDB database.
2. rebdbgui At a GlanceNo setup is required, just do it. >> do %rebdbgui.r The above image was created running REBOL/View 2.7.5.4.2, RebGUI build #93, GNU/Linux 4.0, KDE Desktop. 3. Using %rebdbgui.rRequires REBOL/View, access to a cached copy of RebGUI or internet access for getting a cached copy. The script includes a compressed version of Dobeash's RebDB/db.r. 3.1. Running %rebdbgui.rFrom the library with: >> do http://www.rebol.org/cgi-bin/cgiwrap/rebol/download-a-script.r?script-name=rebdbgui.ror locally with: >> do %rebdbgui.ror from the REBOL/View sandbox with >> do-thru http://www.rebol.org/library/scripts/rebdbgui.r Please note. This script loads itself so if you make a local copy, it will need to match the REBOL header File: %rebdbgui.r field. If you want to call it something else on your local system, you will need to update the File: header field. 4. What you can learnThis script is an introduction to the use of RebDB within a RebGUI application. Both RebGUI and RebDB are available RebGUI gui building is easy, and offers a flexible 'business polish' to application design. There are many features under the hood. RebDB makes persistent storage a breeze, and comes with an SQL flavour. 4.1. REBOL script scanningThis script includes a compressed copy of RebDB/db.r. This allows the script to execute without having to save a copy of the RebDB code. It is worth your while to download the latest and greatest from www.dobeash.com . This script is surrounded in an extra level of [ block markers. This allows for multiple scripts, and it uses select to name the entries. After the main %rebdbgui.r script, there is another block, tagged with the name rebdb. This code is loaded by selecting it, and doing the decompressed source code. You can save this compressed and saved code with the Source Code button. 4.2. do-thruThis example uses the REBOL/View do-thru feature. do-thru will execute a script from the REBOL/View sandbox (another name for cache). It will retrieve the code from the internet, only if there is not a cached copy. If you do develop something with RebGUI, and build it using the REBOL/SDK, you may not have access to do-thru. The RebGUI home site explains all this. This is just an example, and assumes you are using a full fledged REBOL/View. 4.3. append-widgetThis example uses custom RebGUI widgets to get at the database entries inside the data form. The main widget, edit-field is just a copy of the standard RebGUI field with the added benefit of loading itself with data by evaluating the data facet to fill the text facet when the field is initialized. It expects string! data. 4.4. Different strokes for different folksrebdbgui uses quite a few different data update sequences. Some fields are updated and committed to the database with a button. Some fields are updated as each character is typed. One of the fields is updated, but not committed to the database to demonstrate the builtin database replay mechanics. 4.5. The table widgetThis short example highlights the ease and power of the table widget in RebGUI. As just an example, it does no real justice to the full power of table and RebGUI widgets. When running, you can sort the columns, move the splitter, select an entry by simply clicking...and other nifty things. In a blinding example of inefficient programming, the table is updated as part of the data storage function. This is not normal coding practice for a production application. 4.5.1. do-eventsThe standard REBOL event handler is used by RebGUI. do-events is used to start the event handling loop in REBOL. The REBOL/View view function includes a call to this event loop. RebGUI requires it to be called separately, a feature that allows for processing between and around the GUI layout, the display and handling the events. 4.6. What you can change.Go ahead and add entries to the database, but know that the form will need to be updated as well. RebDB includes a handy next feature for integer! key fields, as the id is in the case of testdb. 5. What can breakQuite a few things could break here. REBOL/Core will not have the capabilities to run RebGUI, You will need to start up REBOL/View. 5.1. Needs a local databaseIf you do not allow the creation of the testdb, the script will halt as there is nothing for it to do if there is no database. 5.2. No replay from the sandboxThe Replay Age button will only demonstrate the database uncommitted data replay if everything is in the local directory. Executing with do-thru will break this featurette. 5.3. data-field is experimentalThe code for data-field is somewhat ill-conceived and inefficient, as it will access the database for every gui redraw. It could break. 5.4. Reliance on a particular version of RebGUIThe code needed from RebDB is included, RebGUI is not. The call to append-widget could break at any time as RebGUI is updated. The script will need to include a compatible copy of RebGUI if that happens. Build 95 when written. 6. REBOL/SDKThe RebGUI designer, Ashley Trüter has taken great strides to allow the REBOL/SDK to build a RebGUI application that does not require all the REBOL/View features for a lean, mean application. Full information starts at the RebGUI Home 7. Credits
|