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

World: r3wp

[Core] Discuss core issues

Henrik
14-Aug-2010
[17754]
because LAYOUT sets set-word!s globally. they don't exist in a particular 
context.
Gabriele
14-Aug-2010
[17755]
because make object! only scans for set-word!s in the main block, 
not sub blocks.
Graham
14-Aug-2010
[17756]
view layout [ f1: field button "test" [ use [ f1] [  view/new layout 
[ f1: field "testing" ]]] button "F1 value" [ probe f1/text ]]

this works though
Gabriele
14-Aug-2010
[17757x2]
>> context [do [f: 'something]]
>> f
== something
so you need context [f1: none view/new ....]
Graham
14-Aug-2010
[17759]
I don't want it to overwrite the f1 I have in the global context
Gabriele
14-Aug-2010
[17760x2]
see the VID-CONTEXT function here: http://www.colellachiara.com/soft/libs/utility.r
or, if you want a more general solution, see my implementation of 
modules: http://www.rebol.it/power-mezz/mezz/module.html
Graham
14-Aug-2010
[17762]
thanks .. you've got module for everything!
Gabriele
14-Aug-2010
[17763]
i guess 11 years of reboling pay off sometimes :-)
Graham
14-Aug-2010
[17764x2]
absolutely
so this is like a 'funct for layout
Gabriele
14-Aug-2010
[17766x3]
yes. it's still main block only iirc
but i found it very useful with VID
MODULE instead scan sub-blocks as well and preserves globals by copying 
them.
Henrik
14-Aug-2010
[17769]
I guess I was incorrect. 8 years of REBOLing is not enough.
Graham
14-Aug-2010
[17770]
how exactly do you use it?
Gabriele
14-Aug-2010
[17771x2]
layout vid-context [....]
it will make set-words in there local. i think i had a refinement 
to also get the context in case you need to access it...
Graham
14-Aug-2010
[17773x2]
ok, should work for rebgui too then
vid-context/to
Gabriele
14-Aug-2010
[17775x2]
yep, vid-context/to [...] 'word
(it's a small function so you can easily modify it to fit your needs, 
as well)
Graham
14-Aug-2010
[17777x2]
I have a screen ( VID) and a function that loads values into that 
screen.  I was hoping to reuse that screen elsewhere by enclosing 
into an anonymous context, and use the function that loads the data 
with the same.
so does it make sense to fix make object! to scan for set-words in 
the sub blocks?
Chris
14-Aug-2010
[17779]
You might end up with some rather large objects with lots of redundant 
words - perhaps not so useful for data modelling...
Graham
14-Aug-2010
[17780x5]
Well, instead then a context function that deep scans for all set 
words
I want to be able to reuse these screens I have defined elsewhere 
and the functions that operate on these screens without overwriting 
the original values ...
c: does [ f/text: "hello" show f ] view layout [ f: field button 
"New" [ context [ f: g: none bind [ c ] 'g view/new layout [ f: field 
button "test" [ c ]
] ]]]


this doesn't work ... pressing the test button sets the f field in 
the first window and not the second
c: does [
	f/text: "hello" show f
]
view layout [
	f: field
	button "New" [
		context [
			f: g: none
			bind [c] 'g
			view/new layout [
				f: field
				button "test" [c]
			]
		]
	]
]
should be 

bind [c] g

but still doesn't work
sqlab
14-Aug-2010
[17785]
Probably I do not understand the real intention, but I woud do
c: func [f] [
	f/text: "hello" show f
]
and
button "test" [c f]
Gregg
14-Aug-2010
[17786]
Very cool both Nick and Gabriele.
Graham
14-Aug-2010
[17787x3]
My 'c function references about 20 fields so I want to avoid passing 
the field name as parameter
If it can be solved thru binding .. .?
If it can't I'll just copy the function
Gregg
14-Aug-2010
[17790x2]
Graham, you need to bind the function body.
c: does [
	f/text: "hello" show f
]
view layout [
	f: field
	button "New" [
		context [
			f: g: none
			bind second :c 'g
			view/new layout [
				f: field
				button "test" [c]
			]
		]
	]
]
Graham
14-Aug-2010
[17792x5]
thanks .. I'll give it a go
rebol []

c: does [
	f/text: copy "hello" 
	show f
]
view layout [
	f: field
	button "test - c" [ 
		bind second :c 'show
		c 
	]
	button "Clear" [ f/text: copy "" show f ]
	button "New" [
		context [
			f: g: none
			bind second :c 'g
			view/new center-face layout [
				f: field
				button "test" [
					bind second :c 'g
					c
				]
				button "Clear" [ f/text: copy "" show f ]
			]
		]
	]
]
And this works ....
I can open multiple new windows and the 'c function now works on 
its own instance of f field
( the first 'bind outside of the layout is not needed )
Gabriele
15-Aug-2010
[17797x2]
Graham, use the /to refinement of my VID-CONTEXT and pass the object 
to the function
Gregg, your solution either "breaks" C (in the sense that it will 
only work on the new context and not the others) or does not work 
(on versions of REBOL that copy the function code block - I think 
R3 does this)
Graham
15-Aug-2010
[17799x2]
c: does [	f/text: copy "hello" show f ]

view layout [
	f: field
	button "test - c" [	c ]
	button "Clear" [ f/text: copy "" show f ]

	button "New" [
		context [
			f: g: none
			view/new center-face layout vid-context/to [
				f: field
				button "test" [ c ]
				button "Clear" [ f/text: copy "" show f ]
			] 'c
		]
	]
]

Gabriele, this doesn't work for me ...
assuming that is what you meant :)
Gregg
15-Aug-2010
[17801]
My assumption--never assume, I know--was that 'c would always be 
re-bound before each call. I was looking at the action, not the context 
*in* the action.
Graham
15-Aug-2010
[17802]
Gregg, that's what I did to get it working .. but I'm interested 
to see how Gab's solution would work
Gregg
15-Aug-2010
[17803]
Agreed. Gabriele and others often point out holes in my naive code, 
for which I am always grateful.