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.
>> series? list-dir %./hax KaratInstall.rar metasploit-lat... metasploit-lat... MiniMouseMacro... nemesis-1.4.zip PacketSenderPo... PlayCap-0.1.1-... == false
series!value, that's why
foreachcan't iterate over it
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?
n skipn >= 0 is ok
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 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.
clear is the most memory-saving option.
word: is, and how it is evaluated. It is deeply different from what you would have in another language (like in JS:
v=). Understanding such expression is a key part of understanding Redbol.
word: is data, which eventually gets evaluated. In JS,
v=;is just code.