Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 20 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
Vladimir Vasilyev
@9214
@nedzadarek Parse has a wide range of applications, from simple text processing to metaprogramming and compiler frontend construction, so there's a lot of ground to cover. Catalogue of text search and processing patterns - okay, but explaining how to build a compiler / interpreter, and comparing different approaches to construction of DSLs and general-purpose languages (which are always task and application specific) isn't that trivial.
Ungaretti
@Ungaretti
@nedzadarek My intention is to improve the examples given for each keyword and add snippets. I also want to add three chapters: "Parse usage- Validate inputs", "Parse usage- Extracting data from text" and "Parse usage - Manipulating text", with examples for each (other suggestions welcome). Hopefully that will be enough to get a beginner going with parse.
Currently the website has 11 parse links , including the ones you mention. The current doc, not online yet, has 15, but among them I could not find a simple good example for the if keyword, for example. I got examples for that today here at gitter, btw.
nedzadarek
@nedzadarek
@9214 yes, for bigger things it's better to write a bigger article.
@Ungaretti Certain feature lacks official documentation. Some feature require you to know some terms. I agree - it's not always beginner-friendly. Good luck documenting this 3 chapters. As I tried I know that extracting might be a lot harder/different. Manipulating series might be dangerous so I would say it's "advanced" (beginner+) level.
ps. you can manipulate any series, not only text.
Palaing
@Palaing

What is the right way to refresh text-list face?

mylist: ["one" "two" "three"]
view [text-list data mylist [
    change at face/data face/selected "hi there"
]]                ; text-list is not updated when clicked
print mylist    ; though underlying list is

It does not work better if I add show face
But strangely it works with face/data: face/data:

mylist: ["one" "two" "three"]
view [text-list data mylist [
    change at face/data face/selected "hi there"
    face/data: face/data
]]                ; now text-list is updated when clicked
Semseddin Moldibi
@endo64
Cannot test as I am on mobile, but probably it works because of reactivity that face/data: triggers. you can set a word to your text-list and then examine by probing.
Not sure why it doesn't work with show though.
Palaing
@Palaing
@endo64 actually - my mistake - it does work with show in this example
Palaing
@Palaing

@endo64 it did not in this situation - with a request-text function similar to Rebol's:

view [text-list data mylist [n: face/selected request-text/default face/data/:n show face]]

(face is not updated though mylist has been changed)

Semseddin Moldibi
@endo64
But you do not set face/data? You just show it in request-text
Palaing
@Palaing
@endo64 request-text actually changes mylist - I can check that if I print mylistafterwards.
...or if I unview the layout and view it again
here the new value of face/data is printed, but the face in the view is not updated:
maliste: ["un" "deux" "trois"]
view lay: layout [text-list data maliste [n: face/selected 
    request-text/default face/data/:n print face/data show face
]]
Palaing
@Palaing
But you're right, it works if I explicitly assign a value to face/data:
maliste: ["un" "deux" "trois"]
view lay: layout [text-list data maliste [n: face/selected 
    change at face/data n request-text/default face/data/:n show face
]]
xmonader
@xmonader

I have those packages installed on archlinux

core/lzo 2.10-1 [installed]
core/openssl 1.1.1-1 [installed]
core/openssl-1.0 1.0.2.p-1 [installed]
extra/flac 1.3.2-1 [installed]
extra/wavpack 5.1.0-2 [installed]
community/mbedtls 2.13.0-1 [installed]
multilib/lib32-openssl 1:1.1.1-1 [installed]

core/curl 7.61.1-1 [installed]
community/gambas3-gb-net-curl 3.11.3-3 (gambas3) [installed]
community/libcurl-compat 7.61.1-1 [installed]
community/libcurl-gnutls 7.61.1-1 [installed]
multilib/lib32-curl 7.61.1-1 [installed]
multilib/lib32-libcurl-gnutls 7.61.1-1 [installed]

However, i keep getting segfaults whenever i try reading a webpage from red repl?

nedzadarek
@nedzadarek

It seems that it just doesn't show itself. Here it does it only once:

view [t: text "***" [change t/text to-string random 99 probe t/text probe t2/text] t2: text react [t2/text: t/text]]
"70*"
"70*"
"46*"
"46*"
"57*"
"57*"

I'm not sure if this is a bug.

Vladimir Vasilyev
@9214
@xmonader is that still the case with latest automated build?
@Palaing this suggests that faces are not deep reactors, and do not react to changes in series (e.g. reverse face/data). They will propagate a change only if you modify one of its facets directly, like face/data: ....
Boleslav Březovský
@rebolek
@xmonader I have same problem, I'm on Manjaro (Arch-based distro). What exactly are you doing to triger the segfault? I found problem with libcurl, so I'm curious if there are others.
xmonader
@xmonader
@9214 I used the latest too, ssame thing
@rebolek just calling read, read/info on any url
Boleslav Březovský
@rebolek
@xmonader ok so it's the same libcurl problem. See red/red#2252 and red/red#3402
nedzadarek
@nedzadarek
@9214 they have on-deep-change* but I'm not sure if this have to be used for deep-reactor!s. It might be used for something else... but I don't have time now to check this.
Palaing
@Palaing
@9214 ok I get it. Thanks!
Remigiusz Kozdra
@vejitatoja
I want to create an event that will save the contents of mytext into a file when I'm changing into another tab in tab-panel
How should I do that?
Red [needs: view]

words-as-string: read %words.txt

view [

       Title "Tab-panels"

       tab-panel 200x100 [

               "Tab 1 " [text "First panel"]
               "Tab 2 " [mytext: area 440x215 words-as-string]
       ]
]
dsunanda
@dsunanda
Add an ON-CHANGE to your TAB-PANEL, eg:
 tab-panel  on-change [print ["swapped to tab " event/picked]]
Remigiusz Kozdra
@vejitatoja
on-change fires when changing panels but the unfortunate side effect is that it also fires on every character typed inside mytext area.
Is there any way to make it only react to tab changes?
dsunanda
@dsunanda
Sorry - my mistake. Try ON-SELECT rather than ON-CHANGE
Remigiusz Kozdra
@vejitatoja
on-selectevent also fires on every character typed inside text area but in addition to that also on each mouse click inside text area.
I want to have the ability to automatically save content inside mytext into a file when user will swap to another tab but I want to avoid saving on each keystroke.
Red [needs: view]

words-as-string: read %words.txt

view [

       Title "Tab-panels"

       tab-panel 200x100 on-select [print ["swapped to tab " event/picked]] [

               "Tab 1 " [text "First panel"]
               "Tab 2 " [mytext: area 440x215 words-as-string]
       ]
]
dsunanda
@dsunanda
That's odd - I'm not seeing ON-SELECT respond to anything other than clicking on the tab selections [tab 1][tab 2] - you might have a reportable bug :)
nedzadarek
@nedzadarek
@vejitatoja I think you can check event/picked and save to file depending on that value, something like this:
save-my-text: func [a] [
; just print `text` 
probe a/text
]
view [
    size 400x400
       Title "Tab-panels"

       tab-panel [
               "Tab 1 " [text "First panel" area]
               "Tab 2 " [mytext: area 440x215 return area]
       ] on-change [
        if all [
            event/picked <> 0 ; 0 = selection of non-tab (as fair I can see - no proof!)
            event/picked <> 2 ; 2 is your tab with `mytext` you don't want to save it
            ][  
           save-my-text mytext probe event/picked
                ]
    ] 
]
Remigiusz Kozdra
@vejitatoja
I have discovered that the problem with on-select exist on the new automated build. But it's working correct on old stable red-063.exe It's probably a bug with current version.
Toomas Vooglaid
@toomasv
@vejitatoja Try defining on-select ['done] for area to stop event propagation.
nedzadarek
@nedzadarek
ps. it seems that on-change (and probably more events) are "overreacting". With slider it triggers the on-change even you only click (not changing) on the slider: view [s: slider on-change [print s/data]].
Toomas Vooglaid
@toomasv
@vejitatoja
view [
    Title "Tab-panels"
    tab-panel 200x100 on-change [print ["face/selected:" face/selected "event/picked:" event/picked]] [
        "Tab 1 " [text "First panel"]
        "Tab 2 " [mytext: area 440x215 "Lorem ipsum dolor sit amet, consectetur adipiscing elit." on-change ['done]]
    ]
]
Gregg Irwin
@greggirwin
Another approach is to see if the tab panel is the actual face getting the event.
view [
       Title "Tab-panels"

       tp: tab-panel 200x100 [
               "Tab 1 " [text "First panel"]
               "Tab 2 " [mytext: area 440x215 words-as-string]
       ] on-change [
       if event/face = tp [
            print ["real tab event" "swapped to tab " event/picked]
       ]
       ]
]
If we can dupe the on-select issue, we can file it as a regression. I think there have been some changes there, with panel dragging being fixed up.
Remigiusz Kozdra
@vejitatoja
@toomasv Thanks, Your solution works on the current build. If i understand correctly second on-change that is added for area overrides the top level one? The only issue is that it would mean that i would need to add on-select ['done] to all of the faces that are children of tab-panel.
Remigiusz Kozdra
@vejitatoja
@greggirwin That works. I will go with that solution. Thank you.
Gregg Irwin
@greggirwin
:+1:
nedzadarek
@nedzadarek

@GiuseppeChillemi

is /:ind the same of /(ind) ?

Not exactly. ind in the in the :ind is a word - it is a final value, that you want to look for in the series. (...) is a paren! - you can compute "final value" here. Examples:

arr: [a 11 "b" 22]

ind: 'a
arr/:ind
arr/(ind)
arr/('a)
arr/a

ind: "b"
arr/:ind
arr/(ind)
arr/(back tail "cb")
nedzadarek
@nedzadarek
  • about :ind - I mean word that refers to a final value.
GiuseppeChillemi
@GiuseppeChillemi
@nedzadarek
Some more questions. In RED:
arr: [a 11 "b" 22]
ind: to-lit-word "a"

>> probe arr/:ind
== 11
>> probe arr/(ind)
11
IN REBOL:
>> probe arr/:ind
** Script Error: Invalid path value: a
** Where: halt-view
** Near: probe arr/:ind

>> probe arr/(ind)
11
== 11
nedzadarek
@nedzadarek
@GiuseppeChillemi in the Red, it seems that they added get-word! (:word) select on other values as well.
ps. in the Rebol: arr: [11 22 33] ind: 1 arr/:ind; =11
Vladimir Vasilyev
@9214
@GiuseppeChillemi @nedzadarek get-word! has nothing to do with it
>> block: [a 11 b 22]
== [a 11 b 22]
>> block/(probe quote 'a)
'a
== 11
>> block/(probe to lit-word! "a")
'a
== 11
nedzadarek
@nedzadarek
@9214 I mean get-word! in a path!like <word>/<get-word!> e.g. arr/:ind. I do not mean syntax with a paren!: <word!>/<paren!> e.g. arr/(ind).
And I am not sure how your example relate to the Rebol not being able to get value by <word>/<get-word!> but it can do it with <word!>/<paren!>.
Vladimir Vasilyev
@9214
lit-word! acts as a key selector, not paren! or get-word!, gee.
nedzadarek
@nedzadarek

@9214
1) Both languages can get value based on a number: arr/1.
2) Both languages can get value based on a word: arr/info.
3) Both languages can get value using paren! based on a number/word: arr/(0 + 1), arr/('info).
4) Only the Red can get value based on both a number and a word using get-word!: arr/:w where w is a word or a number.

So based on 3 paren! can acts as numeric/word selector (value from a paren!).
Based on 4 the Rebol has the "problem" with getting value from a get-word!.

In my opinion get-word! is in the centre of the problem.