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
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"]]
     ]
    ]
]
GiuseppeChillemi
@GiuseppeChillemi
Find returns the series at the position of search item, while select returns the ELEMENT after the search item. Is there an istruction to return the POSITION of the ELEMENT after the search item ?
if pos: find series value [pos: next pos]
Something like the code above
nedzadarek
@nedzadarek
@GiuseppeChillemi /tail?
GiuseppeChillemi
@GiuseppeChillemi
@nedzadarek Thanks ! I have not seen it. Tail confuse me with /reverse
nedzadarek
@nedzadarek
find [1 2 3] 2
; == [2 3]
find/tail [1 2 3] 2
; == [3]
well, you can read description (? find)
GiuseppeChillemi
@GiuseppeChillemi
Rearding...
nedzadarek
@nedzadarek
@9214 face's parentand layout/only... I have never thought about it. Thank you.
GiuseppeChillemi
@GiuseppeChillemi

Which is the meaning of maintaining CR in blocks ?

Example:

 a: [aaa
        [ccccc]]

>> append a [bbbb [ccccc]]
== [aaa 
    [ccccc] bbbb [ccccc]]

Are:

[aaa 
    [ccccc] bbbb [ccccc]]

and

[aaa [ccccc] bbbb [ccccc]

The same ?

(Note, for readibility reasons I prefer the former bit I don't know how to add from code in this way)
nedzadarek
@nedzadarek

@GiuseppeChillemi they are the same (unless I don't know something):

a: [a
    b]
;== [a 
 ;   b
;]
aa: [a b]
; == [a b]
a = aa 
; == true

if you want to add newline (I guess that what you mean by CR) then you can just add newline in your code (hit enter):

a: [a]
; == [a]
append a [
    b]
;== [a 
;    b
;]

However certain operations may delete newlines. You can check and set/clear newlines manually using new-line/new-line?:


  arr: [a b c]
; [a b c]
  arr: next arr
; [b c]
  new-line? arr
; false
  new-line arr on ; on = true
; [
;    b c
; ]
  new-line? arr
; true
  head arr
; [a 
;     b c
; ]
GiuseppeChillemi
@GiuseppeChillemi
@nedzadarek so they are totally neutral ? No find/select , etc ?
nedzadarek
@nedzadarek

@GiuseppeChillemi

neutral

Yes, I haven't find any difference.

no find/select

what you mean?

GiuseppeChillemi
@GiuseppeChillemi
Something like Find series newline
nedzadarek
@nedzadarek
@GiuseppeChillemi you can use forall loop:
>> arr: head arr
== [a 
    b c
]
>> forall arr [
[    probe arr
[    print new-line? arr
[    ]
[a 
    b c
]
false
[
    b c
]
true
[c]
false
GiuseppeChillemi
@GiuseppeChillemi
So, forall detects newline and Find and Select do not.
Detects = manage.
While It is trasparent/invisible to Find/select
nedzadarek
@nedzadarek
@GiuseppeChillemi forall doesn't detects anything. It's just a loop that changes position of the series (arr: [1 2 3] > [1 2 3] > [2 3] > ...). new-line? detects new lines.
GiuseppeChillemi
@GiuseppeChillemi
I use the wrong terminology : It does not skip newline
While find/select do skip It.
I am on mobile client for gitter and can't test but Will try "foreach" and lenght? Too.
nedzadarek
@nedzadarek
@GiuseppeChillemi I don't think find/select skip new-line markers on purpose. It's just they are made to do something else. They are made to check values not new-line markers. New-line markers are not "normal values".
foreach won't work because it gives you element of the series. The element doesn't hold information about new-line markers.
GiuseppeChillemi
@GiuseppeChillemi
If lenght? counts new-lines too, I Need to reconsider some routines
nedzadarek
@nedzadarek
@GiuseppeChillemi no, length? doesn't count new lines markers. length? arr; 3
Toomas Vooglaid
@toomasv
@GiuseppeChillemi See also red-by-example