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

World: r3wp

[Core] Discuss core issues

Gordon
2-Jun-2006
[4805]
Hello;
  I'm getting an
   "Internal Error: No more global variable space
     Where: to-word
** Near: to word! :value"


 when i run a program that after reading a file into memory, it then 
 does a character by character parse of the file and writes any words 
 that it finds to a new file.  The code that seems to be causing a 
 problem is this:

    Write/Append OutFileNameFull reduce [to-word WordStr newline]   


It gets through about 1.5 MB before it "runs out of global variable 
space".


Why is it running out of global variable space when there is only 
the one variable (to-word WordStr)?
Oldes
2-Jun-2006
[4806x7]
you reached Rebol's limit - you have declared too many global variables 
with the command to-word WordStr. Do you really need it?
Why you convert it to word anyway?
Write/Append OutFileNameFull join WordStr newline
Nut if I understand it well, you need content of variable which is 
stored in the wordStr
(nut = but)
>> w: "someWord"
== "someWord"
>> reduce [to-word w]
== [someWord]
>> find first system/words 'someWord
== [someWord]
but this is interesting:
>> length? first system/words
== 2600
>> newword
** Script Error: newword has no value
** Near: newword
>> length? first system/words
== 2601
Gordon
2-Jun-2006
[4813x2]
Thanks but WordStr is a string and I need it to be a word type.
Actually, you are right.  Thanks Oldes.  I was able to write it all 
to the file then read it back in and parse it into 'words' without 
using 'to-word'.
Anton
4-Jun-2006
[4815]
This is a frequent stumbling block with beginners - using more words 
than necessary. Words are really good at expressing distinct concepts 
(ie. variables). If you have lots of similar data, then that really 
just calls for a series.
Graham
4-Jun-2006
[4816x2]
Anyone tried printf from the library?
>> do %printf.r
>> printf ["%d" .02 ]
** Access Error: Cannot open sprintf
** Where: routine-call
** Near: routine: make routine! spec library
Gabriele
5-Jun-2006
[4818]
note that r3 will make it easier to create non-bound words (i.e. 
symbols) for the cases when you want to use words as symbols (dialects, 
data, etc) and not variables. anyway, as anton says, i don't think 
anyone would ever really need more than 8k distinct words, so when 
you get that error it means that probably you are doing something 
wrong :) (ah, and given that contexts are extensible in r3, i expect 
the 8k word limit to go away)
Pekr
5-Jun-2006
[4819]
Gabriele - as you mention dialects, will parse see any changes/enhancements 
in R3? Just curious :-)
Gabriele
5-Jun-2006
[4820]
maybe. we've been discussing a few things. nothing decided yet.
Anton
5-Jun-2006
[4821]
I wonder if beginners will take longer to realise the error of their 
ways...
Gabriele
5-Jun-2006
[4822]
anton, yes that could be an issue. maybe we could have a soft limit 
or something like that for contexts. but, i don't know if there's 
an hard limit, i'm just assuming there isn't, but i may be wrong.
Anton
5-Jun-2006
[4823]
They'll find the hard limit when they exhaust memory. :)
Pekr
5-Jun-2006
[4824]
:-)
JaimeVargas
5-Jun-2006
[4825]
Graham, I bet printf is not finding the either the DLL or the function 
on the DLL.
Graham
5-Jun-2006
[4826]
Is this a standard windows dll?
JaimeVargas
5-Jun-2006
[4827x2]
Yes.
Humm. It seems that  WinXP' kernel32.dll doesn't includes the sprintf 
function. I will apreciate if anyone can point to the proper DLL.
BrianH
6-Jun-2006
[4829x2]
msvcrt.dll
That is the C runtime. There are a few other (older) C runtimes on 
Windows, but that is generally the best one.
JaimeVargas
6-Jun-2006
[4831x2]
Thanks Brian.
New printf.r script with fix commited to the library.
Graham
6-Jun-2006
[4833]
Thanks.
JaimeVargas
14-Jun-2006
[4834x6]
Humm. I give up. Has somebody found a solution to the path capture 
problem?

#!/usr/local/bin/rebol -sq
REBOL []
print first system/options/args
What I need is to be able to capture the full path of the first arg 
passed to such script.
Not just the filename.
The reason is that the script is no of the same path of /usr/local/bin 
the script fails to find the file.
Which is passed as arg
Hopefully this is not too convoluted...
Gabriele
14-Jun-2006
[4840]
if you encap it, the CD will be the dir where the program was started 
from. when run with a shebang though... not sure if there's a way.
JaimeVargas
14-Jun-2006
[4841]
No SDK in OSX :-/
Ingo
14-Jun-2006
[4842]
Hi Jaime,
I think you're looking for this

system/script/path
Volker
14-Jun-2006
[4843x2]
probe system/options
IIRC the shell-dir is somewhere there. Or try system/options/script/parent/path.
JaimeVargas
14-Jun-2006
[4845]
Thx, Ingo and Volker, what I was looking for is SYSTEM/OPTIONS/PATH
BrianW
14-Jun-2006
[4846x6]
Dumb question: When I'm printing a string, what's the best way to 
show special characters (^/ etcetera) in their special form, rather 
than just expanding them (turning ^/ into an actual newline, for 
example)?
well, I know probe is the way to do it direct to stdout, but I want 
to save the "probe" value to a string
and for the public record, at least part of my answer is:

raw-str: mold real-str
yay for "source probe"
How about going the other way? Turning newlines into ^/ characters 
and so on?
and again I answer my own bloody question:

replace/all (mold real-text) "^/" "^^/")


Guess I don't actually start thinking for myself until I ask the 
question somewhere that I can look dumb ;)
Izkata
14-Jun-2006
[4852]
But that's the best way - you're more likely to remember it then!
james_nak
15-Jun-2006
[4853]
Is there a way to "copy" an object  (already defined)  so the result 
is a distinct object? It's probably something easy but for the life 
of me...
Anton
15-Jun-2006
[4854]
make