Home   Archive   Permalink



GUI App Maker - Rebol CRUD Builder

http://www.rebol.org/view-script.r?script=gui-crud-app-builder.r
    
Video at: http://www.youtube.com/watch?v=ROL33-Fi2g8

posted by:   Nick       10-Dec-2013/17:43:33-8:00



This is another short demonstration example. 132 lines of code, and the resulting applications (only ~70 lines of code) are easily extended and customized.

posted by:   Nick       11-Dec-2013/8:24:43-8:00



Also, maybe useful as a simple metaprogramming example.

posted by:   Nick       11-Dec-2013/8:26:18-8:00



That's nice Nick!

posted by:   Endo       13-Dec-2013/17:49:04-8:00



Thanks Endo :) It seems like a no brainer to show off Rebol like this. I wonder if there are any other obvious ideas for code builders/generators which could be generically useful. Any ideas?

posted by:   Nick       13-Dec-2013/20:56:52-8:00



I can tell you have become a REBOL master since I look at your code and I can find a single line that I can't understand. I wonder if you would elaborate.
    
I generated a test CRUD application with four data fields, and I am looking at the generated code, for the "delete" function. I see this:
    
dlt: does [
     if true = request "Sure?" [
         temp-block: copy []
         foreach fld fields [
             append temp-block compose do rejoin ["copy " fld "/text"]
         ]
         m: reduce temp-block
         remove/part find f: load filename do rejoin [
             fields/1 "/text"
         ] count
         save filename f clr
         t/data: extract f count
         t/sld/redrag t/lc / max 1 length? head t/lines
         show g
     ]
]
    
All of it is puzzling, and I am going through it, but the totally puzzling line is
    
t/sld/redrag t/lc / max 1 length? head t/lines
    
I think that the purpose of that line is to reset the scroller on the text-area after one line is deleted. I think that the t/sld/redrag and the t/lc are some attributes of a text-area that relate to the built-in scroller, but I don't understand them and have not seen them documented. I am wondering if you have any insights.
    
Thank you.

posted by:   Steven White       15-Jan-2014/17:19:10-8:00



Hey Steve,
    
Yep, that's a stock line that I've included in the tutorials (there are hundreds of practical little bits of code that I've found useful over the years, which have gotten included in the code examples of the tutorials).
    
You'll see in the script that 't refers to a VID text-list style (widget). You can find help for most of the built-in VID objects in system/view/vid . You can use the 'svv shortcut to get to that path faster:
    
     ? svv
    
You'll notice that all the built-in VID styles are in svv/vid-styles, so you can find info about all the properties of the text-list widget like this:
    
     ? svv/vid-styles/text-list
    
You can explore the object directly in the editor:
    
     editor svv/vid-styles/text-list
    
When you're not sure where to find what you want, or if you see a property that you can't figure out, Google is great. Try googling "/sld/redrag", and you'll find a number of explanations and code examples (i.e., there's an explanation of redrag in the second google result, in a script on rebol.org, some examples from codeconscious.com, etc.) Most of what you'll ever need is in those classic references, and Google has had everything I've ever needed well indexed.

posted by:   Nick       15-Jan-2014/21:17:59-8:00



The crudbuilder script is likely to be a little confusing. Notice that most of the code that gets generated is in a string labeled 'builder, at the beginning of the script. The rest of the script gets generated with this code (mostly, it's creating a 'widgets block, from the user's GUI input, in the generated script):
    
         write created-app: to-file join filename/text ".r" rejoin [
             {R E B O L [title: "} filename/text {"]} newline
             "filename: %" to-file filename/text newline
             "widgets: [" newline
             code-area/text newline
             "]" newline builder
         ]
    
The "do rejoin" sections in the generated script are a little metaprogramming thing that I use to generate code on the fly, using items from the fields block.
    
Take a look at http://www.rebol.org/view-script.r?script=crudbuilder.r , and compare the code generated by that section. That should make the whole thing a little more unstandable.

posted by:   Nick       15-Jan-2014/21:44:22-8:00