Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 01 2018 17:34
    @greggirwin banned @BIjeuca_twitter
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:20
    @PeterWAWood banned @TimeSeriesLord
geekyi
@geekyi
I have a little idea of how the debugging red piece of puzzle works a bit now.. I have to organize some links I have tho..
https://papaly.com/ looks like a good social bookmarking service that allows organizing of links into a browsable form. Might be better than putting everything into a gist (drag and drop organizing) Less resilient tho (because they aren't text files)
geekyi
@geekyi
https://papaly.com/#board_id=6c857d19f6854e0cabf209d851a92533 is something I tried, but it's not yet integrated into my workflow..
Would be happy to collab with anyone on a red board!
Michael
@michaeldesu

just experimenting with directories:

>> foreach file list-dir pwd [print file]
%/C/~tools/Red/    red-062.exe            sheet2.xml             TT Archive -20...  *** Script Error: foreach does not allow unset! for its series argument
*** Where: foreach
>> a: dir
    red-062.exe            sheet2.xml             TT Archive -20...  *** Script Error: a: needs a value
*** Where: a

why are the Script Errors occurring? Alternatively, how do you put a list of files into a series block.

Vladimir Vasilyev
@9214
@michaeldesu
>> read %./hax/
== [%KaratInstall.rar %metasploit-latest-windows-installer-x86.exe %metasploit-latest-wind...
>> series? list-dir %./hax
    KaratInstall.rar       metasploit-lat...      metasploit-lat...      MiniMouseMacro...  
    nemesis-1.4.zip        PacketSenderPo...      PlayCap-0.1.1-...  == false
list-dir <dir> returns unset, not series! value, that's why foreach can't iterate over it
Michael
@michaeldesu
@9214 thanks - that was a bit unexpected, but I see file! can be a directory, so I guess it makes sense.
Michael
@michaeldesu

I'm wondering how to get the length of a matched content in a parse statement, without advancing the pointer. I noticed this example on the Red Parse blog:

parse "aaabbb" [copy letters some "a" (n: length? letters) n "b"]

but the pointer advances to the start of the b's. How to get the length of the a's without advancing the pointer?

also to confirm, it's not possible to skip backwards, isn't it? From my testing, seems like for setups like n skip n >= 0 is ok
Michael
@michaeldesu
never mind, I found the answer, it's using ahead
xqlab
@xqlab
You can either use ahead
parse "aaabbb" [ahead copy letters some "a" (n: length? letters) n "b"]
or pos: get an index and set an index ':pos
parse "aaabbb" [ pos: copy letters some "a" (n: length? letters) :pos n "b"]
Michael
@michaeldesu
@xqlab thanks! It's interesting how ahead works, treating the whole copy letters some "a" as a rule (block)
xqlab
@xqlab
How can I edit ?
Michael
@michaeldesu
press the up arrow key, or try clicking on the 3 dots next to your message (edit)
xqlab
@xqlab
Thanks too
sergey
@sergey6661313

how to run red func from #System or routine block?

    Red[]

    my-test-red-func: func [ ] [ print "lal" ]

    #System [
        my-test-red-func
    ]

returned
'* Compilation Error: undefined symbol: my-test-red-func '

Vladimir Vasilyev
@9214
@sergey6661313 you mean this?
Rudolf Meijer
@meijeru
You should put #call in front.
@9214 you beat me :smile:
Vladimir Vasilyev
@9214
:muscle:
sergey
@sergey6661313
Thx!
Alexander Baggett
@AlexanderBaggett
Is there a way to do menu events without actors?
geekyi @geekyi assumes @AlexanderBaggett got the answer in red/help
Michael
@michaeldesu

Please help me understand about initialising a series in a function. I have the following test case. The aim is to have an empty block each time the function is run.

test-me: function [str [string!]] [
    my-series: []
    print [">" my-series]
    foreach x str [append my-series to-integer to-string x]
]

test-me "123"
test-me "456"
test-me "789"

However the output emitted by the print statement in the function shows me the series is not initialised to empty each time the function is called, i.e. I see:

>
> 1 2 3
> 1 2 3 4 5 6

so I guess my-series: [] is not the best way to init an empty series for this case.

xqlab
@xqlab
Use
my-Series: copy []
or
my-Series: clear []
in order to initialize anew
as long as no GC clear [] is recommended
Michael
@michaeldesu

@xqlab thanks alot - clear is good. This is a bit counter-intuitive, unless a series can be like a static variable (in the way I did it). I guess I take it away as another learning :-). The reason why it's confusing is in the REPL it seems to work logically:

>> a: [1 2 3]
== [1 2 3]
>> a: []
== []
>> a
== []

of course it might just be the behaviour in a function is different.

Gregg Irwin
@greggirwin
The REPL does an implicit copy, which is confusing. Learning about copying series is a rite of passage in Redbol. :^)
Michael
@michaeldesu
thanks @greggirwin
Nenad Rakocevic
@dockimbel
@michaeldesu If you create your block dynamically, you would not run into such issue:
my-series: make block! 1 or doing some preallocation: my-series: make block! length? str.
Though, the clear [] is the most memory-saving option.
Michael
@michaeldesu
thanks alot @dockimbel
Michael
@michaeldesu
is it by design that my-series: [] acts like a static variable (i.e. no clear or copy in use), or this is a side-effect of my bad coding
Gregg Irwin
@greggirwin
It is by design.
Michael
@michaeldesu
thanks @greggirwin - ok so it's a potentially useful feature to keep in mind for the future
Gregg Irwin
@greggirwin
And it is true for all series variables in functions.
GiuseppeChillemi
@GiuseppeChillemi
A good question would be: why it has been designed in such a way !
Gregg Irwin
@greggirwin
Yes, it catches everyone not long after they start Reducing, but it is definitely intentional.
Nenad Rakocevic
@dockimbel
@michaeldesu @GiuseppeChillemi There is no specific design rule there, it is just a consequence of how the language works (both Red and Rebol). It boils down to understanding what word: [] is, and how it is evaluated. It is deeply different from what you would have in another language (like in JS: v="", or v=[]). Understanding such expression is a key part of understanding Redbol.
GiuseppeChillemi
@GiuseppeChillemi
@dockimbel Is there any documentation helping us undestand this and the global picture behind this design ?
Gregg Irwin
@greggirwin
See the link I just posted.
Nenad Rakocevic
@dockimbel
@GiuseppeChillemi There is this wiki entry posted by Gregg above, and otherwise, the whole Rebol documentation.
GiuseppeChillemi
@GiuseppeChillemi
Which just disappeared as we lost rebol.com
:(((
Michael
@michaeldesu
agree - that link probably should be required reading by any newcomer
Nenad Rakocevic
@dockimbel
A fundamental cause is that there is no distinction between "code" and "data" in Redbol. word: [] is data, which eventually gets evaluated. In JS, v=[]; is just code.
Michael
@michaeldesu
wow - did rebol.com recently die?