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

World: r3wp

[Rebol School] Rebol School

Rebolek
25-Jun-2007
[422]
then only values in parens get evaluated
PatrickP61
25-Jun-2007
[423]
Works -- Thank you
Geomol
25-Jun-2007
[424]
A suggestion: Many words in REBOL can do more than one thing, sometimes 
depending on data-type of the argument or the use of refinements. 
It's almost impossible to remember it all. So as a new one to the 
language, check the help for the new words, you're learning. Like
>> ? reduce
>> ? compose
PatrickP61
25-Jun-2007
[425]
As a newbie, what suggestions do you have for me to debug my rebol 
scripts.  For example, I have a script called "Convert_to_Table" 
that I am just starting to write.  I can execute it -stand alone- 
and see the results of the run, but what I would like to do is be 
able to see what the console has for any values.  In other words, 
when I double click the "Convert_to_Table" I can see the results 
but not ask the console questions like print Count or the like.  
How do you suggest a newbie debug a script?  Should I go into console 
first and then perform a "do Convert_to_Table" and then be able to 
ask questions of console, or is there another way?.
Geomol
25-Jun-2007
[426x3]
Yes, use the console! Also use PROBE in the script to check values. 
You can put PROBE in anywhere, also in the middle of a sequnce of 
words.
Use some time to really understand probe. I use it all the time.
Carl write about the console here: http://www.rebol.com/docs/quick-start4.html
PatrickP61
25-Jun-2007
[429]
I will check it out
Volker
25-Jun-2007
[430]
I rarely type into the console and probe everywhere in the code. 
there is also '??, which shows the name of the word too.
PatrickP61
25-Jun-2007
[431]
Hi Volker,  after a few variations, I used this: print reduce ["var-name= 
" var-name]  What is the syntax for '??
Rebolek
25-Jun-2007
[432]
?? - it's same as with probe:

>> ?? probe
probe: func [

    {Prints a molded, unevaluated value and returns the same value.}
    value
][
    print mold :value :value
]
PatrickP61
25-Jun-2007
[433]
Ohhh I like the ?? var-name better!
Rebolek
25-Jun-2007
[434x3]
Sorry, I meant ?? works same as ?, not probe
hte advantage of probe is that you can insert it anywhere in your 
code
it prints value to console and returns that value
Volker
25-Jun-2007
[437]
thats true with ?? too (as long as you dump vars) thats the advantage 
over ?
Rebolek
25-Jun-2007
[438x3]
you have for example your code:
	append head copy/part trim string ln "something"

and to easy understand what's going on, you can put 'probe after 
'append, 'head, 'copy/part and 'trim to see how the evaluation is 
going on.
Volker: no, ?? gets 'value and probe gets value as input, so they 
return something different.
probe evaluates, while?? not.
Volker
25-Jun-2007
[441]
but you can put both in the expression
PatrickP61
25-Jun-2007
[442]
Ok to sum up: Probe will return only the value to console, ? will 
return the variable along with short text and value, and ?? will 
return var name with value
Volker
25-Jun-2007
[443x2]
append head copy/part trim  ?? string ?? ln "something" ; works
?? does a get, you can put it in expressions before variables
Rebolek
25-Jun-2007
[445]
Volker: no, ?? changes the meaning of expression in case you put 
it before function:
>> f: func [a][a]
>> a: 1
== 1
>> b: probe f a
1
== 1
>> type? :b
== integer!
>> b: ?? f a
f: func [a][a]
== 1
>> type? :b
== function!
PatrickP61
25-Jun-2007
[446x2]
Wow, I guess there are a lot of ways to "explain" how rebol is evaluating 
an expression.  Thank you.  I will try them all sometime.
P.S.  In AltMe, what do you guys type to get a carriage return without 
sending the AltMe message until you do an <enter>
Rebolek
25-Jun-2007
[448]
It's the "pen" icon, press it and you can send messages with CTRL+S
PatrickP61
25-Jun-2007
[449]
This is a test
This is a test
OK It works!
Anton
25-Jun-2007
[450]
If you hover over the icons, you see the help info text at top left.
Volker
25-Jun-2007
[451x2]
Rebolek, i said  all the time "with variables". Of course it does 
not know what you use as function and what as variable
altme: clicking the pen.
PatrickP61
25-Jun-2007
[453]
Ahhh so much to learn and not enough time!!!  Thanks for your patience
Ok, on to another issue.


I have a text file as a printable report that contains several pages 
within it.  Each line can be as large as 132 columns wide (or less).

- The literal  "    Page " will begin in column 115 and that indicates 
the start of a printed page.


I want to write a script that will read this text file one-page-at-a-time, 
so I can do some processing on the page.


How do I write a script to load in a single "page"?  I am guessing 
that I need to open a PORT and have rebol read all the lines until 
I get "....Page." in bype position 115.

Any suggestions?
Rebolek
25-Jun-2007
[454]
Volker: OK, variables yes.
Volker
25-Jun-2007
[455x2]
you can use read/lines to have all lines in a block
(except if its megabytes^^)
PatrickP61
25-Jun-2007
[457]
I need to load in a single page at a time, then "process" that page 
before going on to the next page and processing it.


Are you suggesting that I go ahead and read in all the lines of the 
report and then go through that block to identify a page?
Volker
25-Jun-2007
[458x2]
if parse/all[115   " "   "Page" to end] ["its a new page"]
(not testet)
if parse/all  LINE [ 115   " "   "Page" to end] ["its a new page"] 
;..
PatrickP61
25-Jun-2007
[460]
I will check out PARSE and try some examples later.

Thanks for your help.  Will be back later
Geomol
25-Jun-2007
[461x2]
Or you can do something like:

fp: open/lines %file.txt
until [
	line: first fp
	if find skip line 115 "Page" [print "new page"]
	tail? fp: next fp
]
close fp
I think, that'll fail, if the file is empty!
PatrickP61
26-Jun-2007
[463]
Hi everyone,


I want to write out a Ruler line to a text file for a specified length 
of bytes similar to the following for 125 bytes in length:

----+---10----+---20----+---30----+---40----+---50----+---60----+---70----+---80----+---90----+--100----+--110----+--120----+

I tried the following code, but not what I want:             Ruler:	for 
Count 10 125 10 [ prin "----+---" Count ]     I got this instead:

----+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+---Ruler: 
120              Any suggestions?
Volker
26-Jun-2007
[464]
make the string without numbers, put the numbers in. with 'at, 'change/part 
ruler num length? num.
Geomol
26-Jun-2007
[465x4]
str: "----+-----"

for Count 10 125 10 [prin join copy/part str 10 - length? to-string 
Count Count]
It's hard to read, sorry, but it's short. :-)
My version produce a lot of copies of the string. Volker's suggestion 
is better, because it don't have these copies, so doesn't disturb 
the garbage collector too much.
doesn't
PatrickP61
26-Jun-2007
[469]
doesn't what?
Geomol
26-Jun-2007
[470]
I corrected myself.
because it *doesn't* have these copies ...
PatrickP61
26-Jun-2007
[471]
Volker -- I'm a newbie so bear with me,  I don't understand your 
suggestion.  Do you mean I should do this:
Ruler: for Count 10 125 10 [ prin "----+-----"    then what?