Red: gui text in array

Created on 1 Aug 2017  路  8Comments  路  Source: red/red

c: "something"
view [ field c ]

is OK.

c: ["something"]
view [ field c/1 ]

Fails with red063 from cask/brew

status.resolved type.review

Most helpful comment

c: ["something"]
view [f: field do [f/text: c/1]]

All 8 comments

Assuming you get the following error:

>> view [ field c/1 ]
*** Script Error: VID - invalid syntax at: [c/1]
*** Where: do
*** Stack: view layout cause-error

What's in the block after view is a dialect / dsl, so Red syntax won't work there.
Come chat in https://gitter.im/red/red/welcome. and check out the docs from http://www.red-lang.org/p/documentation.html.
Particularly https://doc.red-lang.org/en/vid.html

c: ["something"]
view [f: field do [f/text: c/1]]

This actually works in Rebol 2, so I wonder if it's just missing support for path! syntax?

@geekyi is onto something, see:

view [
    across
    b: base transparent 50x50 
        draw  [fill-pen 255.55.0.70 circle 25x25 20]
        react/later [b/draw/2/4: to integer! 255 * s/data]

    s: slider
]

Results in

*** Script Error: VID - invalid syntax at: [react/later [b/draw/2/4: to integer! 255 * s/data] s:]
*** Where: do
*** Stack: view layout cause-error

but this one works

view [
    across
    b: base transparent 50x50 draw [fill-pen 255.55.0.70 circle 25x25 20]
    s: slider

    do [react/later [b/draw/2/4: to integer! 255 * s/data]]
]

@9214, the syntax in VID is slightly different for react/later:

view [
    across
    b: base transparent 50x50 
        draw  [fill-pen 255.55.0.70 circle 25x25 20]
        react later [b/draw/2/4: to integer! 255 * s/data]

    s: slider
]

Words are evaluated, and file or url values are loaded, but paths are not, at this time.

I don't know if it's a design choice or something that just hasn't been needed yet. See: https://github.com/red/red/blob/master/modules/view/VID.red#L180

Just a few cases in VID are allowed to use Red expressions, like after data and at. So the following code will work fine:

c: ["something"]
view [ field data c/1 ]

I don't want to allow to use Red expressions everywhere for now where possible in VID, as that would make it very confusing to many users, who have troubles distinguishing what is regular Red code and what is VID dialect. One option could be to allow it but require a parens around the expression, visually isolating it from the rest of VID. That is used in Parse also, so would feel more familiar. Though, I don't want to make that a mandatory convention in all dialects, each one should be free to define its own semantics and how much mixing the dialect with regular language is allowed.

Was this page helpful?
0 / 5 - 0 ratings