Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
Vladimir Vasilyev
@9214
e.g. lambda [do [?x + 1]]
Instead of using into, @nd9600 for some reason decided to flatten block, thus basically breaking its structure.
yvendruscolo
@yvendruscolo
So its mostly useful for simpler, almost “atomic” functions (like my inc example)
Vladimir Vasilyev
@9214
shrug
>> inc: does bind [x: x + 1] context [x: 0]
== func [][x: x + 1]
>> loop 5 [probe inc]
1
2
3
4
5
== 5
Toomas Vooglaid
@toomasv
@PeterWAWood On W10 vertical alignment seems to work with base (and box), panel, button, check and radio.
Toomas Vooglaid
@toomasv
Er ... rich-text too.
PeterWAWood
@PeterWAWood
Thanks for the confirmation @toomasv
Eric Guedes Pinto
@ericguedespinto
Hi everyone, quick question
What is Red equivalent to rebol’s ‘use’ word?
I thought bind/copy could do the trick but it feels wrong
ne1uno
@ne1uno
@ericguedespinto red doesn't have use, here is one. https://www.irccloud.com/pastebin/GvfMuuE6/use%20for%20red-lang
Vladimir Vasilyev
@9214
@ericguedespinto
use: func [spec body][do reduce [has spec body]]
use: func [spec body][do bind body context collect [forall spec [keep to set-word! spec/1] keep none]]
Eric Guedes Pinto
@ericguedespinto
Thanks
nedzadarek
@nedzadarek

How do you redraw the face/panel? I have something like this:

view [
  p: tab-panel [
    "size" [
      x: field "200"
      y: field "200"
      button "set size" [
        b/size/x: x/data
        b/size/y: y/data
      ]
    ]
    "image" [
      b: base 50x50
      t: text "some text"
    ]
  ]
]

size panel set's the image's base size. However when I change the size panel is not redraw (for example t is on the b).

Vladimir Vasilyev
@9214
show b
nedzadarek
@nedzadarek
@9214 doesn't work
Semseddin Moldibi
@endo64
@nedzadarek can you try to set its text, b/text: ""
once show doesn't redraw that worked for me.
nedzadarek
@nedzadarek
@endo64
You mean this:

view/flags [
  p: tab-panel 333x333[
    "size" [
      x: field "220"
      y: field "220"
      button "set size" [
        b/size/x: x/data
        b/size/y: y/data
        t/text: t/text ; this line?
      ]
    ]
    "image" [
      b: base 50x50
      t: text "some text"
    ]
  ]
;  on-resize [p/size: face/parent/size * 96%]
][resize]
well... it still doesn't work.
Gabriele Santilli
@giesse
i think you'd still need to show
also i suspect a different string may be the trigger @endo64 meant
ah, also notice, he said b/text not t/text
perhaps a bug with show on hidden tab panels?
nedzadarek
@nedzadarek
@giesse it still doesn't work with it:
...
        b/text: append/dup "" "*" 999
        show b
...
Ungaretti
@Ungaretti

Could anyone explain why Red behaves like this:

Red []
csvtext: "first,second,third"
b: split csvtext ","
print b/1
print b/2
repeat i 3 [prin i print b/i]
first
second
1none
2none
3none

In the last line, i is incremented as an integer, but would need a to integer! conversion to work as a proper index.

Boleslav Březovský
@rebolek
@Ungaretti
>> b: [1 2 i 3]
== [1 2 i 3]
>> i: 1
== 1
>> b/i
== 3
>> b/:i
== 1
Semseddin Moldibi
@endo64
Or b/(i) would work.
Ungaretti
@Ungaretti
I see the answer, but i can't figure WHY the i as an index is not evaluated? It becomes a different word? Thanks by the way.
Toomas Vooglaid
@toomasv

@Ungaretti Words are not evaluated by default to allow words to action as keys, I think. E.g.

select b 'i
;is same as
b/i

When used in path, word stands for itselt, unless get-word is used.

nedzadarek
@nedzadarek
@Ungaretti you can retrieve value of a block by:
  • number/index (integer!): bl: [11 22 33 44] bl/2; 22
  • word! - here the Red will look for given word and returns next element: bl: [a 1 b 2] bl/a; 1
  • get-word! - here it will evaluate it (e.g. into number): bl: [11 22 33 44] ind: 1 bl/:ind
  • or paren! - it will evaluate it but you can look for anything: bl: [1.2 a 3.14 b] bl/(1.2); a
Vladimir Vasilyev
@9214
@Ungaretti i is not evaluated because it's a part of a composite value b/i, which is a path!. Same logic applies to [b i], or to quote (b i).
You can use indexing by words to treat series as a key/value store.
Toomas Vooglaid
@toomasv
@nedzadarek Your original example works as expected. When setting size on first tab, you do not change the position of t. E.g. here t-s position is changed. You might do it with react I suppose.
view [
  p: tab-panel [
    "size" [
      x: field "200"
      y: field "200"
      button "set size" [
        b/size/x: x/data
        b/size/y: y/data
        t/offset/x: b/offset/x + b/size/x + 10
      ]
    ]
    "image" [
      b: base 50x50
      t: text "some text"
    ]
  ]
]
Vladimir Vasilyev
@9214
@Ungaretti on the other hand, if you want i to evaluate to integer, use b/:i
Ungaretti
@Ungaretti
Thank you all! @nedzadarek Your answer made me laugh at my own ignorance! I didn't know (or forgot) the fact that Red looks up the list for the word after ´/´and returns the next element. That explains a lot.
nedzadarek
@nedzadarek

@toomasv

t/offset/x: b/offset/x + b/size/x + 10

If you do not know how to do it automatically then I guess nobody knows it. That is what I have started to do, thank you nevertheless.

Toomas Vooglaid
@toomasv
@nedzadarek This is very simple line. How much more automatic you want it? :smile:
nedzadarek
@nedzadarek

@Ungaretti If you haven't used this feature you may forget about it. The Red has many types for key-value things map! for associative arrays, and object! for immutable (keys) container. Not everyone used Lua to know that feature.

@toomasv It is easy but I have to use it many times. I have many 1 more tab and there might be more elements in each tab. It is not a problem but I am just looking for conveniences as vid taught me.

Toomas Vooglaid
@toomasv
@nedzadarek You might do something like this, but you still need to determine same relations:
view/no-wait [
  p: tab-panel [
    "size" [
      x: field "200"
      y: field "200"
      button "set size" [
        b/size/x: x/data
        b/size/y: y/data
      ]
    ]
    "image" [
      b: base 50x50
      t: text "some text"
    ]
  ]
]

react [t/offset/x: b/offset/x + b/size/x + 10]
do-events
nedzadarek
@nedzadarek
@9214 @toomasv Thank you.
Toomas Vooglaid
@toomasv
@nedzadarek You are welcome. This is better:
view [
  p: tab-panel [
    "size" [
      x: field "200"
      y: field "200"
      button "set size" [
        b/size/x: x/data
        b/size/y: y/data
      ]
    ]
    "image" [
      b: base 50x50
      t: text "some text"
    ]
  ]
  react [t/offset/x: b/offset/x + b/size/x + 10]
]
nedzadarek
@nedzadarek
@toomasv :+1:
Toomas Vooglaid
@toomasv

@nedzadarek I'm curious if this might do the automatization?

view [
  p: tab-panel [
    "size" [
      x: field "200"
      y: field "200"
      button "set size" [
        b/size/x: x/data
        b/size/y: y/data
      ]
    ]
    "image" [
      b: base 50x50
      t: text "some text"
    ]
  ]
  do [
    foreach pan pane/1/pane [
        foreach [bas txt] pan/pane [
            if all [bas/type = 'base txt/type = 'text] [
                react [txt/offset/x: bas/offset/x + bas/size/x + 10]
            ]
        ]
    ]
  ]
]

Of course, this is only for consecutive base and text faces. But still?

nedzadarek
@nedzadarek
@toomasv foreach idea is interesting. We can add resize flag and we can almost call it "responsive design".
Toomas Vooglaid
@toomasv
Yeah, if you make base faces responsive to window size, why not.
nedzadarek
@nedzadarek
Well, thank you.
Toomas Vooglaid
@toomasv
:smile:
Ungaretti
@Ungaretti
What does parse's if statement do? It seems it just exit the parsing process if the result is false or none. There is no if-this-do-that? Red blog says it "backtracks", what is that?
Boleslav Březovský
@rebolek
@Ungaretti it works like if-this-do-that. If the condition is true, parse rule continues:
>> block: [1 2]
== [1 2]
>> parse block [set value integer! if (value = 1) to end]
== true
>> block: [2 2]
== [2 2]
>> parse block [set value integer! if (value = 1) to end]
== false