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

World: r3wp

[Core] Discuss core issues

Anton
31-Aug-2005
[1830]
Hey! The rebol.org mail search is pretty good ! Faster than my computer. 
:)
Sunanda
31-Aug-2005
[1831]
Thanks Anton! We had some fun tuning it (it's done with just REBOL 
objects and blocks by the way)--- It should be even faster if implemented 
on your computer as REBOL.org runs (as far as I can tell) on a shared 
1ghz machine with the slowest hard drives outside of a museum.
Geomol
5-Sep-2005
[1832x5]
context question:
If I inside a context block (an object) in one program write:
do %some-program.r

then I can't reach words and functions in the first program from 
the second. I've also tried to bind words to the first context, but 
without luck. Any ideas? Maybe I should put 2 small test-scripts 
here:
prg1.r:

REBOL []
mycontext: context [
do %prg2.r
o: context [
	f: does [print "Hello World!"]
]
f2
]
prg2.r: 

REBOL[]
f2: does [o/f]
I get this error:

>> do %prg1.r
** Script Error: o has no value
** Where: f2
** Near: o/f
If I exclude mycontext from prg1.r binding the words to the global 
context, then it works. But that's not a nice solution.
Ladislav
5-Sep-2005
[1837x3]
this may work:

prg1.r:

REBOL []
mycontext: context [
#include %prg2.r
o: context [
	f: does [print "Hello World!"]
]
f2
]
include %prg1.r
you just have to use my INCLUDE function
Geomol
5-Sep-2005
[1840]
Okay, taking a look...
Ladislav
5-Sep-2005
[1841]
http://www.fm.vslib.cz/~ladislav/rebol/include.r
Geomol
5-Sep-2005
[1842]
Hmm, still doesn't work.
Ladislav
5-Sep-2005
[1843]
checking
Geomol
5-Sep-2005
[1844x2]
REBOL []

do %include.r

mycontext: context [

include %prg2.r

o: context [
	f: does [print "Hej!"]
]

f2
]	; context
That was prg1.r
Ladislav
5-Sep-2005
[1846x2]
wrong
do %include.r can be only in your user.r
Geomol
5-Sep-2005
[1848]
okay
Ladislav
5-Sep-2005
[1849]
and, moreover, copy the example I posted, don't forget #include !
Geomol
5-Sep-2005
[1850x4]
So I do
#include %prg2.r
inside mycontext in prg1.r? And then write
include %prg1.r
to run it?
>> include %prg1.r
** Script Error: o has no value
** Where: f2
** Near: o/f
oops sorry, forgot something. I got it working now.
Thanks!
Ladislav
5-Sep-2005
[1854]
you are welcome, what did you forget, btw? (asking to be able to 
warn other users)
Geomol
5-Sep-2005
[1855]
Mixed include with #include
Ladislav
5-Sep-2005
[1856x3]
yes, that is a gotcha
I should probably write some instructions
do you find INCLUDE useful?
Geomol
5-Sep-2005
[1859]
I wish, something like your include would be part of core. I'm about 
to use such a functionality with my Canvas project, but it's not 
optimal, as it is now.
Ladislav
5-Sep-2005
[1860]
INCLUDE is available for you, it would be even better if you wrote 
a few usage notes
Geomol
5-Sep-2005
[1861]
The functionality is very usefull. (Maybe your include can do a bit 
too much. I like it simple.) Maybe I could just do %include.r at 
the start of canvas.r, so people doesn't have to do it in their user.r 
files. Or I should go another way and make it one big file for now!? 
Hmmm well, I would like to do modules later on, so only the parts 
needed is included.
Ladislav
5-Sep-2005
[1862x2]
generally #include %something means "put here the contents of %something", 
while include %something means "find %something, process it and do 
the result"
regarding your questions: you can use INCLUDE to make a one big file 
if you like
Geomol
5-Sep-2005
[1864]
But as I understand it, rebol doesn't allow contexts to be mix-matched, 
like I would like to do with a simple: do %something.r
Ladislav
5-Sep-2005
[1865x3]
There is a way how to do %include in your files, if required, of 
course
DO doesn't work as that, it simply does the file without including 
its contents
in this case holds, that DO isn't the instrument that can be used 
for this kind of work
Geomol
5-Sep-2005
[1868]
How do I use INCLUDE to make one big file from scripts?
Ladislav
5-Sep-2005
[1869x3]
include/link %input-file %output-file will create a big %output-file
(which contains everything necessary to DO it)
you can try it on your example to see the difference
Geomol
5-Sep-2005
[1872x3]
Like:
include/link %prg1.r %output.r
include/line %prg2.r %output.r
?
line = link
It just makes %output.r the same as %prg2.r
Ladislav
5-Sep-2005
[1875x2]
include/link %prg1.r %complete-prg.r is enough
the %complete-prg.r will contain %prg2.r
Geomol
5-Sep-2005
[1877]
ah! :-)
Gabriele
5-Sep-2005
[1878x2]
one possible "simple" way:
do bind load %prg2.r self