Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 20 2019 22:59
    @dockimbel banned @SmackMacDougal
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
Eric Guedes Pinto
@ericguedespinto
Thank you
Palaing
@Palaing
@9214 Thank you for explanation. Though I'm not sure why this behaviour is good...
Vladimir Vasilyev
@9214
@Palaing why use do does [...] if you can just write do [...]?
Though, I agree that R2 is nicer in this case
>> do func [x y][x * y] 2 4
== 8
Versus Red:
>> do func [x y][x * y] 2 4
== 4
>> do reduce [func [x y][x * y] 2 4]
== 8
Palaing
@Palaing
@9214 because I re-use the function later
so I give it a name at the same time
Vladimir Vasilyev
@9214
do reduce [
    build_specs: does [
        append specs [text "hello"]
    ]    

    build_p: does [
        p_lay: layout specs 
        p/pane: p_lay/pane
    ]
]

view aview
Palaing
@Palaing
@9214 thank you, that's what I looked for!
Toomas Vooglaid
@toomasv
@ericguedespinto Thinking a bit further on your example, it can be solved in spirit of your original example, but three things need to be changed; first, as @9214 said you need to use repeater, any or some; second, you cannot go into rule, because this results in failure -- into rule would have matched your input only at the point where rule matched it, i.e. at 'f cx. You need to go into the second rule - the one in which you are already. And third, you need a skip to hop over unmatched values:
>> rule1: [ 'f set w word! (probe w) ]
== ['f set w word! (probe w)]
>> parse [ a b 'f c1 d [ a b 'f c2 d ] ] rule2: [ some [rule1 | ahead block! into rule2 | skip ] ] 
c1
c2
== true
Toomas Vooglaid
@toomasv

@lepinekong_twitter

is there a way I can select all content in console ?

write/lines %history.tmp gui-console-ctx/cfg/history
Vladimir Vasilyev
@9214
@toomasv system/console/history
Toomas Vooglaid
@toomasv
Good child has many names gui-console-ctx/terminal/history
Vladimir Vasilyev
@9214
@toomasv
>> same? gui-console-ctx/terminal/history system/console/history
== true
Toomas Vooglaid
@toomasv
Of course, there is not a different good child for every name.
nedzadarek
@nedzadarek
Isn't *-ctxleaked objects?
Could be substituted with do in context [...] 'launch I guess, or something similar, to keep object! anonymous.
nedzadarek
@nedzadarek
@9214 yes, but is it intentional or did they just forgot to make them anonymous? There is 2 such objects: help-ctx & gui-console-ctx.
@toomasv :clap: when they improve modules for gui I bet you will contribute the most modules.
ne1uno
@ne1uno
doesn't the menu use gui-console-ctx? why would you want to hide it?
nedzadarek
@nedzadarek
@ne1uno you don't have to have every word in the "global space" to use it. Whenever it's good or bad is up to language designer.
lepinekong
@lepinekong_twitter
@toomasv great accordion ;)
@ne1uno I'm not using old version but I don't keep up with latest build everytime, I'll try with latest since you say ^A had been implemented :)
ne1uno
@ne1uno
lepinekong_twitter, you may have some key translation problem or macro assigned already if it's not working with a recent version. this has worked for quite a while now.
control A that is, ^A is just a common way of describing the key combination
Toomas Vooglaid
@toomasv

@lepinekong_twitter My previous suggestion for writing history into file was inaccurate - it was getting history from latest to oldes, i.e. in reversed form. To get it in right order you have to reverse it beforehand. But as reverse is modyfying command you have to copy the history:

write/lines %history.tmp reverse copy system/console/history

To get only part of history use copy/part system/console/history <length>. <length> may be integer! to get number of lines or,
if you want to copy from certain command, use find, e.g. copy/part hist: system/console/history find hist "do %accordion.red".

To get history until certain point you ccan use at, if you know until which line or how many line you want to get:

; e.g. until line 2, i.e. without the most recent (current) command
copy at system/console/history 2

; e.g. 10 lines from certain command
found: find hist "do %accordion.red" copy/part at hist: system/console/history (index? found) - 10 found

; e.g. 10 lines from 30th command forth
copy/part at system/console/history 30 - 10 10

For getting history directly into clipboard or console I didn't concieve other means than using concat:

write-clipboard copy concat reverse copy system/console/history newline

But beware, writing this to clipboard may put a huge string into your history entry, which may stall your console if you scroll backwards through history.

And finally to just print part of it on console:

print copy concat reverse copy/part system/console/history 10 newline

Without concat you can first write/lines and then read it, to get history with newlines.

There are many more ways to play with history, e.g.

probe concat take/part system/console/history 5 newline

Occasionally your history may become corrupt in the process though. :wink:

nedzadarek
@nedzadarek
@toomasv but is there a way to turn history on and off?
Vladimir Vasilyev
@9214
You can't "turn off" a block which aggregates input data over time.
nedzadarek
@nedzadarek
@9214 I mean turn off this feature, as in, "turn off an 'action' that aggregates input data".
Toomas Vooglaid
@toomasv
@nedzadarek But you can clear it. Or change/part of it to [].
nedzadarek
@nedzadarek
@toomasv yes but every clear / change/part adds something to the history as well.
Vladimir Vasilyev
@9214
It seems to be hardcoded in the top-level loop of console engine, so, no, you can't turn it off.
Though, system/console/history: no doesn't seem to break anything.
Toomas Vooglaid
@toomasv
> gui-console-ctx/cfg/history
== ["gui-console-ctx/cfg/history" "gui-console-ctx/history" "system/console/history" "...
>> gui-console-ctx/terminal/history
== ["gui-console-ctx/terminal/history" "gui-console-ctx/cfg/history" "gui-console-ctx/...
>> system/console/history
== false
Vladimir Vasilyev
@9214
I believe these are aliases for internal buffer, which you can't modify.
Toomas Vooglaid
@toomasv

@nedzadarek

but every clear / change/part adds something to the history as well.

Nope.

nedzadarek
@nedzadarek
@toomasv you are right, my bad.
@9214 then type, for example, 42 + enter in the console.
Vladimir Vasilyev
@9214
>> any reduce [gui-console-ctx/cfg/history system/console/history quote 'disabled]
== disabled
>> 42
== 42
nedzadarek
@nedzadarek
@9214 I mean answer to console: no:
system/console/history: no
42
Vladimir Vasilyev
@9214
I don't follow what you want me to do. All history words are already set to false, that's why any in the example above returns disabled.
lepinekong
@lepinekong_twitter
@toomasv ok thansk for history
nedzadarek
@nedzadarek

@9214 you said:

Though, system/console/history: no doesn't seem to break anything.

You are wrong. As soon as you enter something your console should crash... at least on Red for Windows version 0.6.3 built 26-Mar-2018/1:14:22+02:00.

Vladimir Vasilyev
@9214
If you say so.
>> system/console/history: no
== false
>> 42
== 42
>> about
Red 0.6.3 for Windows built 6-Oct-2018/7:28:28+05:00 commit #dafc828
nedzadarek
@nedzadarek
@9214 good to know that it doesn't cause crash any more. Thank you for this.
nedzadarek
@nedzadarek
How can you add something (e.g. text "1" field "#FF00C8") into one of the tab-panel's panel:
view [
  tabs: tab-panel 400x400 [
     "something" [base red] 
     "dynamic" [
        button "add" [ "some code here" ]
     ]
    ]
]
and I want button to add it after itself.
after 2 clicks on that button should end as:
...
"dynamic" [
   button "add" [ "some code here" ]
   text "1" field "#FF00C8"
   text "2" field "#FF00C8"
]
...
nedzadarek
@nedzadarek

ps. I've tried something like this:

  append/only tabs/pane/(index? find tabs/data "dynamic")/pane [
          text "next color"
]

but it says invalid face type.

Vladimir Vasilyev
@9214
?
view [
  tabs: tab-panel 400x400 [
     "something" [base red] 
     "dynamic" [
        button "add" [append face/parent/pane layout/only [at 100x100 text center middle "yes"]]
     ]
    ]
]