[REBOL] Re: Simple newbie questions
From: carl:cybercraft at: 30-May-2001 22:24
I see Anton's given you a more elaborate example than mine, but here
you go anyway...
This doesn't change real filenames, but just the ones in your
'allfiles block. Use the REBOL word 'rename for that.
More comments below the script...
REBOL [Title: "Rename Files"]
get-files: does [allfiles: read mypath sort allfiles]
view layout [
backdrop effect [gradient 60.0.150 60.10.60]
a-list: text-list data allfiles [
label 53 "Path" a-path: field [
mypath: to-file a-path/text
label "Find" 53 Findme: field
label "Replace" Replaceme: field
Button "Rename" [
replace allfiles findme/text to-file replaceme/text
Note I'd changed your naming of the path in the layout from 'mypath to
a-path, as the one in the layout would conflict with your other
'mypath. Leaving it as it is would cause 'mypath to be pointing to
the field and not your original path.
To get at the data in layout objects such as fields and so on, you
access them and change them like I have in the button above. ie...
returns the text in the objext after the 'findme word, while...
changes the "lines" (a block) in a-list to your 'allfiles block.
updates the list onscreen.
layout objects have a lot of variables such as 'text and 'lines, and a
quick way to see the entire list (after a script has run and the
variables have been set) is to just enter the likes of...
probe first a-list
at the Console. (DO NOT JUST ENTER probe a-list THOUGH AS REBOL WILL
DISSAPEAR ON A VERY LONG QUEST! THE first IS IMPORTANT TO PREVENT
The above returns....
[self type offset size span pane text color image effect data edge
font para feel saved-area rate show? options parent-face old-offset
old-size line-list changes face-flags action state style alt-action
facets related words colors texts file var keycode reset styles init
multi blinker pane-size dirty? help user-data flags sz iter sub-area
sld sn lc lines picked cnt act slf text-pane]
As I said, lots, with many of them not being used, but they're a help
in guessing (and eventually reminding you) how you get at the data in
layout objects. a-list's color for instance can be found by
Hope that's of some help. And yes, we'd all like the full View
On 30-May-01, Jamie wrote:
> Hey Gurus,
> I'm trying to piece together hints from the documentation on Core
> with the "more to come" online docs for View. (I wish there was a
> complete manual for View and Core together that made it all clear.)
> Anyway, as an exercise to help learn this stuff while creating
> something useful, I've started the following View script for
> renaming files.
> I have empty blocks for actions and am not sure what syntax will to
> accomplish what I want.
> I have fields but am not sure how to grab their values and do the
> actual renaming of file names.
> I can describe this in pseudo code but haven't internalized the
> REBOL way yet. There are comments in the script below where I have
> Any suggestions will be most appreciated.
> REBOL [Title: "Rename Files"]
> mypath: %.
> allfiles: read mypath sort allfiles
> view layout [
> backdrop effect [gradient 60.0.150 60.10.60]
> text-list data allfiles  ;desired action is click to fill in the
> selected file into the find field below.
> label 53 "Path" mypath: field ;desired capability is to change the
> path value in the mypath variable and cause the text-list to update
> with the contents of the new path.
> label "Find" 53 Findme: field
> label "Replace" Replaceme: field
> Button "Rename"  ;desired action is click to cause all instances
> of the string in the Find field to be replaced with the string in
> the Replace field, for for every file name in the mypath variable's