World: r3wp
[Rebol School] Rebol School
older newer | first last |
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? |
Geomol 26-Jun-2007 [472] | You could also go for a combination with one little string, that you change (by putting in the number) and print. |
PatrickP61 26-Jun-2007 [473] | I'll see what I do with it ... |
Geomol 26-Jun-2007 [474x2] | I think, Volker meant, you should make one large ruler of 125 chars. |
This is a way without copies: str: "----+-----" for Count 10 125 10 [change skip str either Count < 100 [8][7] Count prin str] | |
older newer | first last |