Home   Archive   Permalink

VID - how to access a runtime named face

Assuming I want to create a Rebol IDE I'll need to access faces which name will only be defined at runtime.
I can create those with for instance make set-word! rejoin [(field-name) b] so I might get grid1, grid2 and so on.
No matter what I try I cannot set those variables working my way from the runtime field-name string:
        set in (make set-word! rejoin [(field-name) b]) 'text "some text"
        show (make set-word! rejoin [(field-name) b])
The following code exemplifies what I am trying to achieve. How do I get the "Refresh fieldname/text" button to work?
By the way when I halt this script, I can probe field-name, but get-face grid1 has no value. Is it specific to the halt script.
Another distinction when I create those fields from within VID, the create block-middle is now a long object listing.
browse-lines: 8
block-end: [
     label "field-name"
     field-name: field "grid"
     button "Create fields" [ do create-fields ]    
     button "Refresh grid1/text" [
        grid1/text: "Text*"
        show grid1
     button "Refresh fieldname/text" [
        ; how to set the runtime created face?        
        set in (make set-word! rejoin [(field-name) b]) 'text "Textx"
        show (make set-word! rejoin [(field-name) b])
     below across
     button "Halt" [halt]
     button "Quit" [quit]
block-middle: []
create-fields: [
         unview layout block-middle    
         block-middle: copy []
         for b 1 browse-lines 1 [
            append block-middle make set-word! rejoin [(field-name) b]
            append block-middle to-block join [ text ] (join "Test" b)
         append block-middle block-end
         view layout block-middle
append block-middle block-end
view layout block-middle

posted by:   VIDpuzzle       24-Jan-2019/20:52:53-8:00

On this line here:
     append block-middle make set-word! rejoin [(field-name) b]
You are joining the face object with the iterator to create the set-word. This should probably error out, but doesn't. To get the value of the field, use GET-FACE (similarly you can use SET-FACE to update a face's content.
     append block-middle make set-word! rejoin [get-face field-name b]

posted by:   Chris       24-Jan-2019/23:30:41-8:00

I've recommended elsewhere that COLLECT is an expressive way to build a new block:
     ; no block-middle
     create-fields: [
         view layout collect [
             repeat b browse-lines [
                 keep make set-word! rejoin [get-face field-name b]
                 keep 'text
                 keep join "Test" b
             keep block-end
     view layout block-end

posted by:   Chris       25-Jan-2019/0:28:52-8:00

I switched to one liners trying to find out how to update the make set-word! from the CLI
>> make set-word! rejoin [get-face field-name b]
== grid5:
How am I going to use a set-word! to access the grid5 object?
What works
>> set in grid5 'text "Textx"
== "Textx"
The solution I look for
>> set in make set-word! rejoin [get-face field-name b] 'text "Textx"    
** Script Error: in expected object argument of type: object port
** Where: func [face value][halt]
** Near: set in make set-word! rejoin
** Script Error: show expected face argument of type: object block
** Where: func [face value][
     b: 5
     show make set-word! rejoin [get-face field-name b]
I know the object exist. What reference do the accessors need?
>> probe first grid5
[self type offset size span pane text color image effect data edge font para feel saved-area rate show? options parent-face old-offset old-size line-list changes face-flags action state access style alt-action facets related words colors texts images file var keycode reset styles init multi blinker pane-size dirty? help user-data flags doc xy]
== [self type offset size span pane text color image effect data edge font para feel saved-area rate show? options parent-face old-...

posted by:   VIDpuzzle       25-Jan-2019/11:10:04-8:00

Off-topic, if you are trying to create a REBOL IDE, I would not presume to say I have done so, but I have gathered together some of my ideas for streamlining the process of writing programs into what is basically a menu-driven program launcher. I use something like it at work regularly, so I took what I did for myself, sanitized it of anything related specifically to me, and put it somewhere where others could could have it if they might find it useful. You are welcome to it for any ideas it might provide. It is a zip file called RPE2.zip and can be found at the bottom of the list at the following location. Unpacking the zip file will produce a folder called RPE2, and within that will be a DOS batch file called run-RPE-windows.bat which will run the main program called RPE2.r. I had hopes of packing it in such a way that it would run on Macintosh and GNU/Linux also, but circumstances made it difficult to test those options.
The index page is here: http://cobolrebol.com/pages/freestuff/freestuff-index.html

posted by:   Steven White       25-Jan-2019/11:28:58-8:00

By IDE I mean add faces to a screen at runtime. For instance allow to create a field within a list-box for instance to create a form or even a button opening a new screen.
I launched your little IDE on Linux. Working fine and I will use it. Nice to have a bunch of tools together there.
The console button does nothing.
I might send your way a coupe of things I use myself or just add it to my own version.

posted by:   VIDpuzzle       25-Jan-2019/15:04:25-8:00

Keep in mind that LAYOUT is just a helper function. Its main layout functions are done at the point of invocation, after that it's all faces and panes.
The nifty part of this is you can manipulate faces as you would any other piece of Rebol data--faces (even window faces) are just objects which may or may not have a FACE/PANE value that contains more face objects.
The frustrating part is that to adapt to changes, you have to manage positions and sizes yourself--whether that is incorporating new content or handling resizing.
If you're interested in hacking around with Rebol/View, I'd suggest looking at the links on this page (some solid research there):
You may also find some techniques here useful:
(contains a few different experimental ideas on layout/animation/resizing, amongst other things)

posted by:   Chris       25-Jan-2019/20:59:31-8:00