• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp64
r3wp928
total:992

results window for this page: [start: 301 end: 400]

world-name: r3wp

Group: All ... except covered in other channels [web-public]
Sunanda:
13-Mar-2006
I'd like a basic cross-platform data manager of the sort Ashley suggests.

That can then be used to build SQL type databases for those who want 
them. 

Or list type databases (for people like me who use that sort of approach 
a lot)
Or whatever.
No need to prematurely bind to the relational model/
Steeve:
29-Mar-2009
context [
	stack: make block! 10
	foreign-rules: make block! 10
	out: end: value: pos: none
	push: func [type][
		stack: change/only stack out 
		out: make type 1 
	]
	pop:  to-paren [
		stack: back stack 
		out: append/only stack/1 out
	]
	set-&: [end: (misc/&: to string! copy/part pos end)]
	misc: context [
		&: none
		keep: func [&][append out &]
	]
	blanks: charset " ^-^M"
	rules: [
		  some [blanks | #"^/" (new-line out true)]	  
		| pos: foreign-rules
		| [#"]" | #")"] (print "missing [ or (" return stack/1)
		| #"[" (push block!) any [#"]" pop break | rules]
		| #"(" (push paren!) any [#")" pop break | rules]

  | (set [value pos] transcode/next/error pos append out value) :pos
	]
	
	set 'load-foreign func [
		text [string!] foreign [block!]
	][
		out: make block! 10
		stack: change/only clear head stack out
		clear foreign-rules
		foreach [rule code] foreign [

   append foreign-rules compose [(rule) set-& (to-paren bind code misc) 
   |]
		]
		append foreign-rules  [end skip]
		parse/all to-binary text [any rules]
		bind out 'system
		either 1 = length? out [first out][out]
	]
]
Steeve:
29-Mar-2009
Ok, in the following version (much simpler) i just add foreign data 
as error objects in the stream.
Then you can reparse the result to manage errors as you want.

context [
	stack: make block! 10
	out: value: pos: none
	push: func [type][
		stack: change/only stack out 
		out: make type 1 
	]
	pop:  to-paren [
		stack: back stack 
		out: append/only stack/1 out
	]
	blanks: charset " ^-^M"
	rules: [
		  some [blanks | #"^/" (new-line out true)]	  
		| [#"]" | #")"] (print "missing [ or (" return stack/1)
		| #"[" (push block!) any [#"]" pop break | rules]
		| #"(" (push paren!) any [#")" pop break | rules]

  | pos: (set [value pos] transcode/next/error pos append out value) 
  :pos
	]
	set 'load-foreign func [
		text [string!] 
	][
		out: make block! 10
		stack: change/only clear head stack out
		parse/all to-binary text [any rules]
		bind out 'system
		either 1 = length? out [first out][out]
	]
]
Group: Core ... Discuss core issues [web-public]
Joe:
22-May-2006
IMy understanding is that if you bind a word to the local context 
then it's a local even if it's not defined in the spec but I probably 
have multiple misunderstanding (though I just read the Bindology 
Bible by Ladislav)
Joe:
22-May-2006
I see. This is a major limitation. I see the rebol3 has a blog entry 
that "bind expands contexts" How could I approach this with the current 
rebol ?
Pekr:
22-May-2006
Today I reread the blog, and I was not comfort with the idea that 
simple bind should auto-extend context ... maybe just my internal 
feeling, dunno .... just wanted to state opinion of less experienced 
reboller :-)
Anton:
22-May-2006
Eval-template will accept a template string
1) convert to block
2) extract the words
3) create a context with these words
4) unset all words in the context

5) do your code bound to the context   ( do bind your-code the-context 
)
6) handle errors
7) return results
Joe:
22-May-2006
template:  	to block!  "<html><head><title> title </title></head><body>tag1 
tag2 tag3</body></html>"

blk:		remove-each val copy template [tag? val]	 ?? blk ; == [title 
tag1 tag2 tag3]

eval-template: func [
	/local res title tag1 tag2 tag3
][
	res: 		copy ""

	bind/copy 	blk 'res

	title: 		"hey"
	tag1: 		"this is tag1^/"
	tag2: 		"i am tag 2^/"
	;tag3: 		"might not be set^/"

	repend 		res bind/copy template 'res
	res
]


probe eval-template
Ladislav:
22-May-2006
;This is one way how to do it:
eval-template: lfunc [template [string!]][] [
	res: 		copy ""

	bind/copy 	blk 'res

	title: 		"hey"
	tag1: 		"this is tag1^/"
	tag2: 		"i am tag 2^/"
	;tag3: 		"might not be set^/"

	repend 		res bind/copy to block! template 'res
	res
]

see http://www.fm.tul.cz/~ladislav/rebol/lfunc.rThis would throw 
an error if the tag3: line is commented
Anton:
22-May-2006
make-template-context: func [
	template
	/local words spec
][
	words: remove-each val to-block template [tag? val]

	spec: words
	forall spec [spec/1: to-set-word spec/1]
	append spec none

	context spec	
]

eval-template: func [
	template-ctx
	code
	/local err
][

 unset bind next first template-ctx template-ctx  ; unset all words 
 in the context
	do bind code template-ctx  ; do the code

	; Check if any tags were not set

 if find next second template-ctx unset! [ ; were any tags not set 
 ?
		print "Some tags were not set!"
		foreach word next first template-ctx [
			if not value? in template-ctx word [
				print [word "is unset!"]
			]
		]
	]
]

; now test


template: "<html><head><title> title </title></head><body>tag1 tag2 
tag3</body></html>"

template-context: make-template-context template

eval-tags: [
	title: "web page"
	tag1: "tag1"
	tag2: "tag2"
	tag3: "tag3"
]


eval-template template-context eval-tags  ; <- this sets all expected 
tags and is ok

eval-template template-context [] ; <- this doesn't set any tags 
so will complain and show all unset tags
Henrik:
26-Jul-2006
how does one avoid that variables listed in a block in an object 
become global in this instance:

>> unset [a b c]
>> y: make object! [a: [b c d] set a [1 2 3]]
>> a
** Script Error: a has no value
** Near: a
>> b
== 1
>> c
== 2
>> d
== 3

These give the same result:

>> y: make object! [a: [b c d] set bind a self [1 2 3]]
>> y: make object! [a: [b c d] set bind/copy a self [1 2 3]]
>> y: make object! [a: copy [b c d] set a [1 2 3]]
>> y: make object! [a: bind [b c d] self set a [1 2 3]]
Rebolek:
21-Sep-2006
Certainly not the most elegant sollution:
set-path: func [pth val /local rslt][
	rslt: copy []
	head insert/dup head rslt [in get] -1 + length? pth

 repeat i length? pth [append rslt to block! form to path! reduce 
 ['pth i]]
	set do bind rslt 'pth val 
]
Henrik:
21-Sep-2006
do reduce bind [to set-path! [a b c] 7] 'a does not seem to work
Ladislav:
21-Sep-2006
do reduce bind [to set-path! [a b c] 7] 'a does not seem to work

 - right, that is not supposed to do anything meaningful, it simply 
 keeps the context the word 'a had
Ladislav:
21-Sep-2006
If 'a does not have meaningful context, then bind [...] 'a cannot 
repair the situation
Gabriele:
9-Jan-2007
Anton, you need a BIND there somewhere :)
Anton:
10-Jan-2007
This works:
	use-forall: func [
		words data body
	][
		use words compose/deep [
			forall data [
				set [(words)] bind data/1 'data
				(bind body 'data)
			]
		]
	]
	
	; test
	
	data: [
	
		[code description]
	
		["CC" "Crazy Cuts"]
		["DD" "Dreadful Dingo"]
		
	]
	
	use-forall data/1 next data [
		print index? data 
		if code = "CC" [print description]
	]
Chris:
10-Jan-2007
I think this is pretty sturdy -- an interesting exercise in context 
wrestling:

use-foreach: func [words records body][
    bind body first words: use words reduce [words]
    foreach record records [set words record do body]
]
Anton:
10-Jan-2007
- Nested blocks in the user code might require BIND/COPY.
- [throw] (?)
- [catch] (?)
Chris:
10-Jan-2007
Using compose, I could get the word! argument working:

bind body first words: use words compose/deep [[(words)]]
Volker:
10-Jan-2007
; more commented:
use-foreach: func [words records body /local fresh-locals][
    ; make fresh locals for the args
    fresh-locals: use words reduce  [words] ; trick
    ; bind body to one of  the new locals
    bind body first fresh-locals
    ; now loop
    foreach record records [
        set words record 
        do body
    ]
]
Chris:
17-Jan-2007
uses: func [args [block!] spec [block!][
    args: context args
    func [options [block!] compose/only [
        options: make (args) options
        do bind (spec) in options 'self
    ]
]
Chris:
17-Jan-2007
uses: func [args [block!] spec [block!]][
    args: context args
    func [options [block!]] compose/only [
        options: make (args) options
        do bind (spec) in options 'self
    ]
]
Graham:
10-Feb-2007
eval-math: func [ exp [string!]
	/local t allowed okay
][
	allowed: [ + - / square-root log-e * ]
	t: to block! exp
	bind t '+
	okay: true
	allowed: [ + - / square-root log-e * ]
	foreach e t [
		switch/default type?/word e [
			paren! [ eval-math form e ]
			word! [ if not find allowed e [ okay: false break ]]
			decimal! []
			integer! []
		][ okay: false break ]
	]
	either okay [
		do t
	][ none ]
]
Graham:
10-Feb-2007
eval-math: func [ exp [string!]
	/local t allowed
][
	allowed: [ + - / square-root log-e * ]
	t: to block! exp
	bind t '+
	foreach e t [
		switch/default type?/word e [
			paren! [ if none? eval-math form e [ return none ]	]
			word! [ 
				if not find allowed e [ 
					print [ "not allowed is : " e ]
					return none
				]
			]
			decimal! []
			integer! []
		][ return none ]
	]
	do t
]
Gabriele:
11-Feb-2007
graham: why are you using to-block there? (my assumption is that 
you wanted to avoid the binding of load, but then you manually bind 
to the global context, so you can just use load)
Gabriele:
11-Feb-2007
a different approach is to create a context with only the words you 
want to allow, then use to-block, then bind it to your context only, 
then do it.
Volker:
11-Feb-2007
in-shadow-context: use first system/words['some-word]

then bind to 'some-word. somewhat  expensive, but you do it only 
on input. 

Escapes: it  does not go into #[object![..]]. I have  a function 
which does  that too.  ifthe user can do a  stringwith a new word, 
that  word is still global.
Graham:
11-Feb-2007
Yes, I want to bind it to a different context to be safe .. so exactly 
how do I create this different context for all the math stuff?
Group: View ... discuss view related issues [web-public]
Henrik:
25-Aug-2005
not so wonderful:
>>layout [a: field "rebol" b: field "rules"]


>>fields: make object! [atext: in a 'text btext: in a 'text] ; how 
to bind a/text and b/text correctly?
>>fields/atext
== text ; word! incorrect

or:

>> fields: make object! compose [atext: (in a 'text)  btext: (in 
b 'text)]
>> fields/atext
== "rebol"

but then:
>>set in fields 'atext "test" ; incorrect way, apparently
>>fields/atext
== "test" ; good

>>a/text
=="rebol" ; but it didn't propagate back to the face....
DideC:
16-Nov-2005
Anton: or you can double bind your code block to ctx-text and system/view
DideC:
16-Nov-2005
view/new layout [
	the-field: field feel [
		engage: func [face act event] bind bind [
			switch act [
				down [

     either equal? face focal-face [unlight-text] [focus/no-show face]
					caret: offset-to-caret face event/offset
					show face
				]
				over [
					if not-equal? caret offset-to-caret face event/offset [
						if not highlight-start [highlight-start: caret]
						highlight-end: caret: offset-to-caret face event/offset
						show face
					]
				]
				key [
					edit-text face event get in face 'action
				]
			]
		] in ctx-text 'self in system/view 'self 
	]
	new-field: field
]
focus the-field
do-events
Henrik:
30-Nov-2005
what is it exactly that 'WITH does in LAYOUT? I can assign variables 
to face data, but apparently not face data to variables... I'd like 
to bind the state of a toggle to an external variable in a toggle
Henrik:
30-Nov-2005
oh... it's because text is bound to a string, where you can't bind 
to TRUE and FALSE...
DideC:
16-Dec-2005
edit-text binding : IIRC you have to bind it to ctx-text and maybe 
system/view too.


set in ctx-text 'edit-text func [args] bind bind [newfunc] ctx-text 
system/view
(or something of this kind)
Anton:
16-Mar-2006
>> layout [p: panel with [ctx: none insert init [ctx: context [b: 
none] bind second :action ctx]][b: button]]
>> ctx
** Script Error: ctx has no value
** Near: ctx
>> b
** Script Error: b has no value
** Near: b
>> p/ctx/b/style
== button
Pekr:
17-Apr-2006
I asked my friend about Ruby, Python - as my idea was, that corporations 
should throw out tools like Delphi, VB .... .NET and JAVA are goliath 
... but he told me, that Python has to bind to other gui toolkits 
and that it is not so integrated .... he then mentioned AJAX, killing 
all needs for anything like View ... but - just go and find some 
statistics ... look at W3C and look for the state of support for 
all that MLs in recent browsers - you will find situation quite messy 
...
Ingo:
28-Apr-2006
Did anyone try to patch the behaviour of area? Especially I'd like 
to have:
- autoindent

- doubleclick on words in the area to do something interesting - 
e.g. look up in dictionary, use like a wiki word, ...
- maybe add additional shortcut keys.


I've tried to patch ctx-text/edit-text, but only was able to get 
no change at all, or crashes. Seems to be a bind problem:
ctx-text/edit-text: func[][] ;no change

ctx-text/edit-text: func[] bind [] in ctx-text 'edit-text ; unknown 
word ...
DideC:
29-Apr-2006
You need to bind in ctx-text AND system/view (double bind)
Anton:
1-Jun-2006
ctx-viewtop: context ctx-viewtop

do bind [if block? ctx-prefs-gui [ctx-prefs-gui: context ctx-prefs-gui]] 
ctx-viewtop
;do bind [slide-to email-settings] ctx-viewtop/ctx-prefs-gui
do bind [
	use [face][

  face: foreach face prefs-face/pane [if all [face/style = 'tog face/text 
  = "Email settings"][break/return face]]
		face/feel/engage face 'down none
	]
] ctx-viewtop/ctx-prefs-gui
ctx-viewtop/view-prefs
Volker:
18-Jun-2006
probe first system/view 
probe get in system/view/event-port 'awake 
make system/view [source wake-event] 
system/view/wake-event: func [port /local event no-btn] bind [
    event: pick port 1 
print remold [event/type event/offset event/key] 
    if none? event [

        if debug [print "Event port awoke, but no event was present."] 
        return false
    ] 
    either pop-face [

        if in pop-face/feel 'pop-detect [event: pop-face/feel/pop-detect 
        pop 
            -face event
        ] 
        do event 
        found? all [
            pop-face <> pick pop-list length? pop-list 
            (pop-face: pick pop-list length? pop-list true)
        ]
    ] [
        do event 
        empty? screen-face/pane
    ]
] system/view 
echo on 
print "con" 
view layout [button "test" [probe "test"]]
Volker:
18-Jun-2006
system/view/wake-event: func [port /local event no-btn] bind [
    event: pick port 1
print[type? event]
if event! = type? event[ 
print remold [event/type event/offset event/key] 
]
    if none? event [

        if debug [print "Event port awoke, but no event was present."] 
        return false
    ] 
    either pop-face [

        if in pop-face/feel 'pop-detect [event: pop-face/feel/pop-detect 
        pop 
            -face event
        ] 
        do event 
        found? all [
            pop-face <> pick pop-list length? pop-list 
            (pop-face: pick pop-list length? pop-list true)
        ]
    ] [
        do event 
        empty? screen-face/pane
    ]
] system/view 
echo on 
print "con" 
view/new layout [button "test" [probe "test"]]
Henrik:
9-Aug-2006
how do you bind layout words to an object easily? I want to set faces 
to variables which are supposed to be local to the context of my 
Tester program. I realize this is really the old "dynamic variable 
list in an object problem" all over again (I run into this very often 
it seems), but was wondering if LAYOUT specifically allowed some 
tricks...
Anton:
21-Aug-2006
; Redraw action SHOW occurs first, then DRAW.

view center-face layout [
	f: field feel [
		crt: none 
		append body: second :redraw bind [

   either act = 'show [crt: system/view/caret system/view/caret: none][system/view/caret: 
   crt]
		] body/3/2
	]
	field 
	do [focus f]
]
Group: I'm new ... Ask any question, and a helpful person will try to answer. [web-public]
BrianH:
15-May-2009
One interesting thing to note is that because the data in the objects 
is blocks, MAKE will bind/copy the blocks to the new object. This 
is why you don't have to copy the blocks explicitly when you make 
a new object based on the proto.
mhinson:
24-May-2009
Hi, I am reading about BIND, but I cant understand the concept of 
what it is for. Is there something I should understand first perhaps?

The function summary http://www.rebol.com/docs/words/wbind.html
description is what I am starting with, but I dont understand what 
the examples demonstrate.
Paul:
24-May-2009
being new, it probably isn't good to tackle bind just yet.  Bind 
is more advanced concepts.
Paul:
24-May-2009
'bind is used to bind a word or words to a context.
Henrik:
24-May-2009
mhinson, BIND is all about contexts. A word is usually bound to a 
specific context (or object if you will), giving it a specific value 
that exists in that context. You can have:

a: make object! [
	b: 7
]

c: make object! [
	b: 9
]


'b is a word, but for 'c, it has one value and is bound to 'c's context. 
'a is a different context where 'b has different value.
Henrik:
24-May-2009
So if you are in a situation where you have the unbound or incorrectly 
bound word 'b, BIND will allow you to change its context:

>> do [b]
** Script Error: b has no value
** Near: b

; no context above, so we bind:

>> do bind [b] c
== 9


This allows you also to refer to words inside a specific context 
without path notation.
Paul:
24-May-2009
mhinson, when I made Tretbase 1.0 engine, I used Bind quite a lot. 
 The only time I really like to use 'bind is when I have iterations 
where performance is an issue.   That way I could write a block of 
code and then just bind it into a logic based loop.  This way I didn't 
have to record additional loops to meet the logic.
mhinson:
24-May-2009
I think I have understood what it is that has been preventing me 
from understanding BIND.

I was expecting BIND to make a persistant difference to the contexts, 
but now I have realised that is not the case, it only acts as a function 
to return information when it is called.  That was a tough one to 
fight through.   However, now I understand Henrik's example, but 
the example in the manual still confuses me.  
words: [a b c]

    fun: func [a b c][print bind words 'a]  ;; why is this not  ... print 
    bind words 'a 'b 'c]

Does this mean that bind causes fun to be joined to the context of 
words, for all the variables used in the words context? 

I think I am also still confused about which direction the context 
moves.  Sorry to be asking again, but I do want to understand this 
completely. In Henrik's example it seems to be "do b in the context 
of c" but in the manual example it seems more like "print words (which 
in the global context ) as if the context variables of words had 
been assigned the values of the current context....  I am off to 
bed now to sleep on it.   Thanks.
mhinson:
25-May-2009
I see the bind function can do both the things I noticed above.  
I have stalled with reading Ladislav's Bindology paper at section 

9.1 I dont understand what a-word has become, and why.  I dont understand 
how 'a might be referenced in   bind 'a a-word   as it has no mention 
in the example, so I dont understand what is being demonstrated.
Steeve:
25-May-2009
words: [a b c]					;**  words, a, b, and c belong to the global context.

fun: func [a b c][print bind words 'a]		;** 'it is asked to change 
the context of the words comprise in the block "words".

      ;** After that, they are not belonging to the global context anymore, 
      but to the context of the function.
mhinson:
25-May-2009
Thanks Steeve, I think bind is becoming a bit clearer to me. Your 
comments seem to make sense to me now.
BrianH:
25-May-2009
Words are immediate values, so BIND returns a new value when passed 
a word. BIND changes blocks passed to it, but BIND/copy changes a 
deep copy. The words in blocks are replaced with new words that have 
the same symbol but a different binding.
Steeve:
29-Nov-2010
if its an internal (silent) reconstruction we don't bother.
the behavior acts like a change.
a: [obj]
bind a context [obj: 1]
do a
== 1

From my point a view the serie A has bit been modified.
BrianH:
29-Nov-2010
But the interesting thing is that the immutability of words makes 
BIND behave differently when passed a word (which it can't modify) 
versus a block (which it can). So when you bind a block, you aren't 
modifying the words in the block, you are modifying the block itself. 
This is an important distinction that we shouldn't gloss over because 
that tends to confuse newbies later.
MagnussonC:
30-Nov-2011
Is there a LDAP module with authentification available for R2? I 
tried ldap-protocol.r from softinnov.org, but didn't get that to 
work (with anonymous bind) ... Not sure why I get "Error: Invalid 
port spec". I'm on Win7 (x64). Maybe it is something on OS level 
I have to config to use ldap://!?
Endo:
1-Dec-2011
Try using FIRST, SECOND and THIRD on your object, that's what words-of 
and body-of do for object values.
>> bind remove first x x
>> third x
Endo:
1-Dec-2011
I'm also working on very similar to your case right now. I don't 
know if its useful for you but here how I do (on Windows)


command: {csvde -u -f export.ldap -d "ou=myou" -r "(objectClass=user)" 
-s 10.1.31.2 -a "" "" -l "DN,sn,uid,l,givenName,telephoneNumber,mail"}

call/wait/console/shell/error command %export.err  ;export all users, 
bind annonymous

if 0 < get in info? %export.err 'size [print "error" editor %export.err 
halt]
lines: read/lines %export.ldap

;create an object from the first line (field names, order may differ 
from what you give in the batch)

ldap-object: construct append map-each v parse first content none 
[to-set-word v] 'none
foreach line lines [
	(
		set words-of o: make ldap-object []  parse/all line {,}
		append users: [] o
	)
] ;append all valid users as an object to a block
probe users

I hope it gives some idea.
Group: Parse ... Discussion of PARSE dialect [web-public]
BrianH:
17-Mar-2008
Does a bind/copy on its code block every time it is used.
Henrik:
11-May-2008
if I have a rule-block that does not exist in the same context as 
the main parse block, is there a simple way to rebind it without 
composing it into the main parse block? my current solution is to 
bind it to a temp block and use the temp block as a rule in the main 
parse block, which is less than optimal, I think.
Henrik:
11-May-2008
set 'html-gen func [
    "Low level HTML dialect"

    data [none! string! tag! url! number! time! date! get-word! word! 
    block!]
    /local cmd blk header row-blk start-tag dr tr pr wr
  ] [
    if get-word? data [data: get data]

    if any [url? data string? data number? data word? data time? data 
    date? data] [out data return true]
    if none? data [return true]

    dr: bind data-rules 'data ; this is the easiest way? can we not bind 
    directly in the parse block?
    tr: bind tag-rules 'data
    pr: bind page-rules 'data
    wr: bind word-rules 'data
    parse data [any [cmd: [dr | tr | pr | wr]]]
  ]
Chris:
11-May-2008
Assuming you want to assign values to function locals from the external 
parse rules, you can a) bind as you are doing, b) create a larger 
context for the function encompassing your rules or c) compile the 
parse rule, either on creation of the function or for each instance.

a)
rule: [set tag tag!]
test: func [data /local tag][bind rule 'data parse data rule tag]

b)
test: use [tag][
    rule: [set tag tag!]
    func [data][parse data rule tag]
]

c)
rule: [set tag tag!]
test: func [data /local tag] compose/only [parse data (rule) tag]


Also, note that when you bind, it alters the original block -- no 
need to reassign to a new word.
Henrik:
12-May-2008
the function is recursive, so that may put a twist on b). I forgot 
that detail with BIND on a) so thanks for that. c) seems to work 
best.
Anton:
5-Nov-2008
Right - so doing an extra bind may slow things down.
BrianH:
6-Nov-2008
In R2 you just bind the words to system/words, or LOAD instead of 
TO-BLOCK.
Steeve:
5-Sep-2010
ah ok thanks for the translation.
BIND and BIND? are the keys
Ladislav:
5-Sep-2010
It is quite hard to decipher what actually Micha meant, I suppose, 
he wanted this?

rule: ["text" (var: "local")]

var: "global"

f: func [/local var] [parse "text" bind rule 'var return var]
BrianH:
10-Sep-2010
Ladislav, true. But since PARSE doesn't really recurse, the only 
direct way to have local variables would be to BIND/copy the parse 
rules for each level of recursion. Doing the function recursion method 
is actually more efficient and easier than that.
Gregg:
13-Sep-2010
set 'use-rule func [

    "Create a recursion and thread-safe parse rule with local variables. 
    R2/R3 compatible."
    words [block!] "Local word(s) to the parse rule"
    rule  [block!] "Parse rule"
] [
    make object! [

        ; Create a new function context. 'Inner-body refers to a function 

        ; with access to CONTEXT-FN's context without being influenced 
        ; directly by the context.
        spec: copy [/local]
        append spec words
        inner-body: func ['word] [inner-inner-body word]
        context-fn: func spec reduce [:inner-body first words]
        

        ; Bind the rule the caller gave us to the new context we just created.
        inner-inner-body: func [word] [bind/copy rule word]
        bound-rule: context-fn
        

        ; Now define the use rule. Because this is an "active" rule,
        ; with state we need to include some state variables used
        ; by the internal PARSE call ('pos and 'success).
        pos: none
        success: none
        inner-inner-body: func [word] [

            ; If the parse of the rule succeeds, we set the parse position

            ; to the where the rule match ended, otherwise we don't change

            ; the parse position and use [end skip] to return a false 
            ; result (for R2 compatibility).
            success: either parse pos [bound-rule pos: to end] [
                [:pos]
            ] [
                [end skip]
            ]
        ]
        set 'rule copy/deep [pos: (context-fn) success]
    ]
    rule
]
Gregg:
13-Sep-2010
set 'use-rule func [

    "Create a recursion and thread-safe parse rule with local variables. 
    R2/R3 compatible."
    words [block!] "Local word(s) to the parse rule"
    rule  [block!] "Parse rule"
] [
    make object! [

        ; Create a new function context. 'Inner-body refers to a function 

        ; with access to CONTEXT-FN's context without being influenced 
        ; directly by the context.
        spec: copy [/local]
        append spec words
        inner-body: func ['word] [inner-inner-body word]
        context-fn: func spec reduce [:inner-body first words]
        

        ; Bind the rule the caller gave us to the new context we just created.
        inner-inner-body: func [word] [bind/copy rule word]
        bound-rule: context-fn
        

        ; Now define the use rule. Because this is an "active" rule,
        ; with state we need to include some state variables used

        ; by the internal PARSE call ('pos and 'success). They are used to 
        ; "transfer" the inner parse state to the "outer parse".
        pos: none
        success: none
        inner-inner-body: func [word] [

            ; If the parse of the rule succeeds, we set the parse position

            ; to the where the rule match ended, otherwise we don't change

            ; the parse position and use [end skip] to return a false 
            ; result (for R2 compatibility).
            success: either parse pos [bound-rule pos: to end] [
                [:pos]
            ] [
                [end skip]
            ]
        ]
        set 'rule copy/deep [pos: (context-fn) success]
    ]
    rule
]
Gregg:
13-Sep-2010
set 'use-rule func [

    "Create a recursion and thread-safe parse rule with local variables. 
    R2/R3 compatible."
    words [block!] "Local word(s) to the parse rule"
    rule  [block!] "Parse rule"
] [
    make object! [

        ; Create a new function context. 'Inner-body refers to a function 

        ; with access to CONTEXT-FN's context without being influenced 
        ; directly by the context.
        spec: copy [/local]
        append spec words
        inner-body: func ['word] [inner-inner-body word]
        context-fn: func spec reduce [:inner-body first words]
        

        ; Bind the rule the caller gave us to the new context we just created.
        inner-inner-body: func [word] [bind/copy rule word]
        bound-rule: context-fn
        

        ; Now define the use rule. Because this is an "active" rule,

        ; with state, we need to include some state variables used

        ; by the internal PARSE call ('pos and 'success). They are used to 
        ; "transfer" the inner parse state to the "outer parse".
        pos: none
        success: none
        inner-inner-body: func [word] [

            ; If the parse of the rule succeeds, we set the parse position

            ; to the point where the rule match ended, otherwise we don't 

            ; change the parse position and use [end skip] to return a false 
            ; result (for R2 compatibility).
            success: either parse pos [bound-rule pos: to end] [
                [:pos]
            ] [
                [end skip]
            ]
        ]
        set 'rule copy/deep [pos: (context-fn) success]
    ]
    rule
]
Group: !RebGUI ... A lightweight alternative to VID [web-public]
OneTom:
30-Oct-2005
i would like to bind an action to the pgup/pgdn key when im in field 
widgets preserving all the predefined keybindings of course
ChristianE:
26-Mar-2006
Ashley (and others): As RebGUI is designed to stay short and clean, 
chances are, that users want to do own custom styles which aren't 
subject to become part of the standard distro but rather be added 
on a per project basis. With the latest change to e.g. SET-SIZES, 
I for now don't see how to do that in a compatible manner:


In case a user likes to have his widgets respond to unit- and font-size 
changes as the standard widgets do it looks like one has to patch 
SET-SIZES, or am I missing something? You reset all standard  widgets 
there in one central location, which is very elegant, but it looks 
as you have no chance of knowing about styles added later with 

        CTX-REBGUI/WIDGETS: MAKE CTX-REBGUI/WIDGETS [... new widgets here 
        ...] BIND IN CTX-REBGUI 'SELF


May I suggest some mechanism in the widgets FEEL, something like 
RESET or RESIZE, which simply get's triggered from within SET-SIZES 
for all widgets. A RESIZE feel function would have the benefit of 
keeping simply size-changing-related calculations out of the usual 
REDRAW which I'd prefer to be reserved for rapid state changes thru 
user interactions and content changes.


Then, in SET-SIZES you'd simply do some FOREACH WIDGET/WIDGETS [WIDGET/FEEL/RESIZE 
WDIGET NEW-SIZE WIDGET/FEEL/REFONT WIDGET NEW-FONT] 


On the other hand, I'm sure you had good arguments on why not to 
feature an explicit resize and refont mechanism. But me I never understood 
why e.g. RESIZE wasn't in VIEW/VIDs shared FEEL contexts, too, and 
now I'm facing kind of a deja vu with RebGUI ... ;-)
Volker:
1-Apr-2006
Even if you bind them somewhere else?
Robert:
1-Apr-2006
But than I need to write a special bind block too. That's double 
work. Once in the GUI code, once in the bind block.
Graham:
24-Jun-2006
I am creating templates which I load up and display.  These templates 
contain some variables for label widths etc.  I have to bind the 
template to the variables, but then if I do that, operators such 
as '- have no context.  do I have to redefine '- and '+ etc?
Graham:
24-Jun-2006
do %rebgui.r


test: {label "This is a label" (width) radio-group data [ "-" "+" 
] return label "Another label" (width - 5)}

go: func [ template [string!] 
	/local width
][
	width: 20
	template: compose bind to-block template 'width
?? template 
	display "testing ..." [
		(template)
	]
]


go test

do-events
Graham:
24-Jun-2006
test: {label "This is a label" (width) radio-group 24x4 data [ "-" 
"+" ] return label "Another label" (width - 5)}

go: func [ template [string!] 
	/local width
][
	width: 30
	template: compose bind to-block template 'width
	display "testing ..." compose/deep [
		(template)
	]
]

go test
do-events
Graham:
25-Jun-2006
actually the way it works now, since I have to bind the block to 
my local variables, doesn't that mean I have adequate protection?
Anton:
21-Oct-2006
display "" [my-text: text 32x10 "0:00:00"] 
do bind [
	font: svv/vid-styles/banner/font 
	effect: [gradient 0x1 0.0.150 0.0.50]
	feel: make face/feel [
		engage: func [face action event][
			if action = 'time [
				face/text: now/time ; <-- set the time as you wish
				show face
			]
		]
	]
	rate: 1
	show self
] my-text
do-events
Graham:
9-Feb-2007
template: copy somearea/text
		template: compose/deep bind template 'wide

		display "title" compose/deep [
			(template)
		]
Group: Rebol School ... Rebol School [web-public]
PatrickP61:
7-Apr-2009
I've been reading up a little on generating errors at http://rebol.com/r3/docs/concepts/errors-generating.html
one line in particular captured my attention:


The error message generated for my-error can be printed without stopping 
the script:

disarmed: disarm err
print bind (get disarmed/id) (in disarmed 'id)
this doesn't go into that using my-function

-- Not sure if this has any legs for me?
Oldes:
7-Apr-2009
I'm ussing:
attempt: func [value][
    either error? set/any 'value try :value [
        print parse-error disarm value none
    ] [get/any 'value]
]
parse-error: func [
    error [object!]
    /local type id arg1 arg2 arg3 wh
][
    type: error/type
    id: error/id
    wh: mold get/any in error 'where
    either any [
        unset? get/any in error 'arg1
        unset? get/any in error 'arg2
        unset? get/any in error 'arg3
    ] [
        arg1: arg2: arg3: "(missing value)"
    ] [
        arg1: error/arg1
        arg2: error/arg2
        arg3: error/arg3
    ]

    rejoin ["** " system/error/:type/type ": " reduce either block? system/error/:type/:id 
    [
            bind to-block system/error/:type/:id 'arg1
        ] [
            form system/error/:type/:id
        ]
        newline

        reform ["** Where: " wh newline "** Near: " mold error/near newline]
    ]
]
Janko:
12-Jun-2009
I have one question ... I have parse blocks stored in some external 
block:  parsers: [  aaa [ ( variable + 1 ) to abc ] ]  so I do select 
parsers 'aaaa to get that block .. and then I >>parse string get-parse-bock<< 
 


The problem is that "variable" in that block is defined in the function 
where parse happens ... and it's undefined inside parse block in 
this case ... any ideas how to bind it to it's outer variable... 
I haven't used bind or use before but I thought I can do something 
like this with bind .. but I can't make it work and I also don't 
"get" the bind example in docs
Janko:
12-Jun-2009
hm.. it seems I was using the parameters reverse and bind is exactly 
for this :)
Janko:
12-Jun-2009
...
I don't get this example:
    >> words: [a b c]
    >> fun: func [a b c][print bind words 'a]
    >> fun 1 2 3
    1 2 3

You give it just 'a to bind but is seems to bind b and c too??
Davide:
12-Mar-2010
I need a small function "my-compose" that takes a blocks, deep search 
tag! values and change it with the value of the word into the tag.
For example, if I have a test function like this:

x: 1
test: func [y /local z] [
	z: 3
	my-compose [ 
		print [ <x> + (<y> + <z>)]
	]
]

Calling:

test 2 

should return:

>> [print 1 + (2 + 3)]

My problem is to do the right bind in the parse:

my-compose: function [code [block!]] [elem rule pos] [
	rule: [any [

  pos: set elem tag! (change/only pos **magical-bind-here** to word! 
  to string! elem ) |		    	
		pos: any-block! :pos into rule |
		skip
	]]
	parse code rule
]
BrianH:
15-Mar-2010
Strangely enough, the BIND function has a keyword that DO doesn't: 
'self.
Ladislav:
15-Mar-2010
Strangely enough, the BIND function has a keyword that DO doesn't: 
'self.

 - as far as I know, 'self is not a keyword for Bind in R2, but it 
 is a keyword of the object spec dialect.
BrianH:
15-Mar-2010
Right, Ladislav, I forgot to mention that it is R3's BIND that has 
the 'self keyword.
BrianH:
16-Mar-2010
Andreas, MAKE function! doesn't execute the code in the code block, 
it just makes the function. Your workaround applies to the code when 
it is executing. When the function is being made, the words 'return 
and 'exit will be treated specially in the function code block (if 
we go definitional for those functions), but when the code is run 
later the words are nothing special. It's similar to the situation 
with 'self and BIND or MAKE object!.
BrianH:
16-Mar-2010
Easy to bind, the word is in the spec block.
, "Extra value on function frame." It doesn't mention two values.
Steeve:
14-Apr-2010
Jeez , I don't need of the bind stuff...

remoldx: func [x /all /flat /only][

 do probe remove-each ref copy 'mold/all/flat/only [not get ref] reduce 
 x
]
BrianH:
3-Jul-2011
Much cheaper on R3 than R2 - LOAD does a lot of work. Note that TO-BLOCK 
doesn't bind any words in the resulting block, which can come in 
handy sometimes.
Gerard:
12-Jul-2011
I think the same about every different aspect of REBOL for newbies. 
this is what misses from the actual doc. 


When we limit ourselves to use REBOL as another procedural orand 
 functional language, it's relatively easy to master but when we 
have to delve more deeply into other aspects which would require 
more tools - or a more precedently acquired deepness about languages 
internals (kike globals storage allocastion and representation vs 
local ones in contexts and functions for example or even the bind 
mechanism - then there is some missing parts.


And I agree, this is the same for Parse and the way constructs have 
to be thought to eventually become a master  at creating new patterns 
easily - not mimicing others without learning (this is the first 
step nevertheless - whatever we are using which is new and we never 
met before ) ... 


Carl already resolved some part of this challenge with his Cookbook 
and How-to guides but more material needs to be covered and parse 
fits this need ... 


Not to formal and not too informal is the rule and the way to go 
from my POV.  : )
Janko:
20-Dec-2011
is there already any way to turn block to object like data: [ a 1 
b "c" ]  ===> data: make object! [ a: 1 b: "c" ] so I could >> do 
bind [ print a ] data ; or do I have to do that "manually" ?
BrianH:
24-Dec-2011
What's weirder (only tested in R3 so far): Once the function is created 
its argument words are bound to the internal function context, and 
bindings are by position in the context (though BIND determines this 
position from the name at binding time). That means that after the 
function is created, the displayed argument block is just documentation 
- the real argument list is the function context. This means that 
if you create the function using MAKE directly and keep a reference 
to the spec block, then change that spec block, the changes don't 
affect the function's behavior or what WORDS-OF returns. Like this:

>> a: [a] b: make function! reduce [a [print a]]
>> b 1
1
>> change a 'b
== []
>> b 1
1
>> source b
b: make function! [[b][print a]]
>> words-of :b
== [a]

>> help b
USAGE:
        B a

DESCRIPTION:
        (undocumented)
        B is a function value.

ARGUMENTS:
        b
301 / 992123[4] 5678910