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

World: r3wp

[Rebol School] Rebol School

Gregg
22-Jun-2007
[410]
I have some big books I like, but my favorites tend to be smaller. 
I love Jon Bentley's books, and anything by Robert Glass (almost 
wrote Philip Glass there :-), Kernighan, and DeMarco and Lister are 
other favorites.
Graham
22-Jun-2007
[411x3]
I actually bought some HP tough paper for this purpose.  It's water 
proof and and can be printed upon with laser printers.
and very expensive
So, I can debug my programs in the bath :)
Geomol
22-Jun-2007
[414]
:-D
PatrickP61
25-Jun-2007
[415x2]
Hi everyone,
I'm a newbie and wanted to ask this question on a simple rebol program. 
 If I have a variable COUNT and I wanted to write this value with 
a literal could I do this:  write OutFile [Count " Total lines"]/append. 
 But the word Count is not evaluated and I get "Count Total lines" 
instead of "8 Total lines".  What do I need to tell rebol to return 
the value of COUNT?
Rebolek
25-Jun-2007
[417]
hi Patrik,

try this:

write OutFile reduce [Count  " Total lines"]
PatrickP61
25-Jun-2007
[418]
Rebolek - Does the word REDUCE evaluate all values in the block?
Rebolek
25-Jun-2007
[419]
yes
PatrickP61
25-Jun-2007
[420]
Thank you -- I'll try it
Rebolek
25-Jun-2007
[421x2]
If you do not want to evaluate everything, use compose:
compose [(count) " Total lines"]
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"] 
;..