r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

Sunanda
12-Mar-2009
[11954]
:xxxx -- gets you the value of xxx
mold -- makes it a string
Steeve
12-Mar-2009
[11955]
or you can use the clipboard
IN R3:
write clipboard:// to-binary mold :list-dir
(similar in R2)
PatrickP61
12-Mar-2009
[11956]
I noticed that under HELP LIST-DIR, the arguments state 

    path -- Accepts %file, :variables, and just words (as dirs) (file! 
    word! path! string! unset!)

I get the first two ie  %/c and  :VAR-DIR, but what about "just words..."
Can anyone give examples of the third type of argument?
Steeve
12-Mar-2009
[11957x2]
it doen't work currently, i think it's a bug, ask Brian before to 
post a new bug
it should work as-is to my mind
list-dir c
(same as list-dir %/c)
BrianH
12-Mar-2009
[11959x3]
The relevant portion of the LIST-DIR source is this:
    switch type?/word :path [
        unset! []
        file! [change-dir path]
        string! [change-dir to-rebol-file path]
        word! path! [change-dir to-file path]
    ]
You should try SOURCE MORE for a simpler example of this method.
LIST-DIR is one of the console interactive functions, so it is acceptable 
for it to have an optional parameter without a refinement - otherwise 
you should avoid that method. The function you should use inside 
code, rather than interactively, is READ.
LIST-DIR currently needs work (mostly better formatting), but the 
behavior you describe is by design.
Steeve
12-Mar-2009
[11962x2]
In R3, have we a function to replace a list of values by anorther 
one currently ?
(don't remember)
in a string
Robert
12-Mar-2009
[11964]
Can someone enlighten me: Will we have the Wiki and Carl's R3 docs 
side-by-side? Isn't that a double effort? I don't get it.
Geomol
12-Mar-2009
[11965]
About LIST-DIR:

R3 have some UNIX kinda commands, like ls. I think, Carl was tired 
of typing:
list-dir %script
and just wanted to type:
ls script


But it doesn't work with /c, because it's seen as a refinement datatype, 
and ls doesn't allow that. It's a mistake, as I see it. You can do 
it by:

myls: func ['path] [ls (form path)]
myls /c
PatrickP61
12-Mar-2009
[11966]
Thanks for your comments Brian, Steeve and Geomol
BrianH
12-Mar-2009
[11967x4]
Geomol, refinement support sounds like a good idea, but it was left 
out on purpose because /c would work but /c/d would not. It is better 
to get people out of the habit now than it is to have to explain 
why /c/d doesn't work, over and over again.
Steeve, try REWORD - it is not a modifier though, it builds a new 
string.
There is a plan to add this as an option to REPLACE as well, and 
that is a modifier.
Robert, the R3 docs are a manual, while the wiki is community-generated 
articles and such. Not the same thing.
Steeve
12-Mar-2009
[11971x4]
hmmm... reword doesn't fit well in my case.

i want to replace sequences of replace/all on the same string. I 
saw this scheme in many scripts (not mines of course:)

replace/all data ... ...
replace/all data .. ...
replace/all data ... ...

Cirst attempt could be:

foreach [this by] values [
	replace/all data this by 
]

but it would be slow.
hmm... it works with reword with an empty escape option:

>> reword/escape "Hello you" [#"l" #"L" #"o" #"O"] ""
== "HeLLO yOu"
In fact, i don't see the need of  an escape caracter by default ("$"), 
it should be the reverse.
For the case of only replacing chars by another ones, reword build 
to much overhead
BrianH
12-Mar-2009
[11975]
Like I said, there are plans to make a modifier version of REWORD 
as an option of REPLACE. The escape character makes sense for template 
word substitution use, the main purpose of REWORD - it was Carl's 
idea.
Geomol
12-Mar-2009
[11976]
Brian, makes sense with the refinement and ls. :-)
BrianH
12-Mar-2009
[11977x2]
Steeve, one of the problems with multiple value replace is that there 
are basically two ways to do it:

- One value/replacement pair at a time (like your FOREACH loop above).

- In order using either an inner loop of FIND/match calls, or PARSE 
rules and alternation.

Neither of those are very efficient, but the PARSE rules tends to 
be more so, at the expense of building the rules. REWORD uses the 
compiled PARSE rules method. Most of its overhead is working around 
bugs in map! or going away with new REBOL features. If we do an inplace 
replacement, we'll have the same overhead. The only solution is to 
optimize the runtime, or hand-write the PARSE rules.
I've basically decided to bite the bullet and optimize the runtime. 
The feature requests and bug reports that came from implementing 
REWORD will be much more valuable than REWORD itself. That's why 
I wrote it :)
Steeve
12-Mar-2009
[11979]
i make a proposal:

Most of the times, we use the same rules several times on different 
data.
reword should be able to not reconstruct the rules if so.

I used the similiar tricks in some scripts, for example:

map-chars: func [
	{replace/all pair chars in a string}
	data [string!] values [block!]
	/local chars pos
][

 ;** if the first value in values is a bitset, do not reconstruct 
 the bitset
	unless bitset? chars: first values [
		chars: make bitset! 256
		forskip array 2 [append chars array/1]
		insert values chars
	]
	pos: data
	values: next values

 while [pos: find pos chars][pos: change/part pos select/skip values 
 first pos 2 1]
	data
]

data: "Hello You"
map-chars copy data values: [#"s" "SS" #"t" #"T"] 
;** the second call is faster
map-chars copy data values
[unknown: 5]
12-Mar-2009
[11980]
Cool Steeve.  You should be a way bigger part of the REBOL team.
BrianH
12-Mar-2009
[11981]
Replacing single characters is all you need? That isn't general enough 
to make it into REBOL, but it might be a good library function.
Steeve
12-Mar-2009
[11982]
bah, to be here and in Rebdev is good enough for me
BrianH
12-Mar-2009
[11983]
You do help already :)
Steeve
12-Mar-2009
[11984x2]
Brian, it was just an example to show reusable rules
In your case, it could be an object or a parsing rules instead of 
a bitset
BrianH
12-Mar-2009
[11986]
I like functions that generate functions, if that helps :)
Steeve
12-Mar-2009
[11987]
yes or a funtion :)
Geomol
12-Mar-2009
[11988]
Playing with icons: http://www.fys.ku.dk/~niclasen/rebol/R3/icons.png
Robert
13-Mar-2009
[11989]
Docs/Wiki: I know the difference. How much content is overlapping? 
I see a problem if we maintain two lanes of documentation regarding 
concepts etc.


It's again the fragmentation problem that makes it so hard to get 
R2 details collected and structured.


IMO the Wiki is one of the best things that happend to Rebol. Finally 
most information in one place.
[unknown: 5]
13-Mar-2009
[11990]
Cool John.  I favor a glosser look myself.
Henrik
13-Mar-2009
[11991]
http://hmkdesign.dk/r512.png

An old icon I did a few years ago.
Geomol
13-Mar-2009
[11992]
Henrik, that font is closer to the old icon. Did you create it or 
got it from somewhere?
[unknown: 5]
13-Mar-2009
[11993]
Looks good also Henrik.
Henrik
13-Mar-2009
[11994]
I made it in SVG. I can't remember how I did the R, but I think I 
took an Arial Bold and made some adjustments.
[unknown: 5]
13-Mar-2009
[11995x2]
I like John's R a bit better.
But I like the size of Henrik's.
Henrik
13-Mar-2009
[11997x2]
There is also an r256 and r128, if you want to compare sizes.
But I guess we can't cheat. Was the requirement that we did the icon 
in DRAW?
Geomol
13-Mar-2009
[11999x2]
I don't think so. Carl just said, we plan to go with an old script 
and change colors in that.
we = he
Henrik
13-Mar-2009
[12001x2]
Geomol, I made a very primitive SVG importer for R3. it can only 
handle one shape in one color, but it's nice if you need to draw 
it by hand. If you need it for complex shapes, let me know.
http://rebol.hmkdesign.dk/files/r3/gui/093.png

Some shapes in this image was done that way.
Geomol
13-Mar-2009
[12003]
Ok, I'm waiting for some reply from Carl, if he needs any of our 
help.