• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[Rebol School] REBOL School

Evgeniy Philippov
28-Apr-2012
[161x4]
Could anyone tell, Is rebol a language for sketching systems, or 
is it a full-fledged Turing-full language with access to all machine's 
resources? Seems to be a sketching one, IMHO. Could anyone comment 
on this?
Not intending to start a religious war, but it's interesting what 
opinions about such and other qualities of rebol people have.
I have almost zero experience at programming in rebol.
Or is Rebol an OverForth type language which is too syntactically 
*liquid* to use in long-term industrial and long-term stable projects? 
Could anyone comment?
Gregg
28-Apr-2012
[165]
REBOL is a full-fledged, high-level language. I use it for commercial 
work. R2 is very stable, but does have a small number of things that 
may never be fixed. Only you can say if they would cause you problems. 
The bigger issue is that RT doesn't seem to be maintaining REBOL 
anymore. The hope is that Red, World, and others will mature enough 
to be viable options.
Henrik
28-Apr-2012
[166]
rebol a language for sketching systems

 - nevertheless, REBOL is also excellent for prototyping things that 
 need to be done in another language.
Sunanda
28-Apr-2012
[167]
REBOL is structured more like LISP or Haskell (but without being 
a pure functional language).


So, yes, it does not have direct access to the machine instructions 
or low-level op sys APIs in the way that assembler or assembler-wrapper 
languages (like C) does.


What REBOL does have is easy integrated access to very high level 
APIs: parse. bind, map, etc.
Sujoy
3-May-2012
[168]
beginner question:
i'm opening a file using
    d: open/direct/lines %bigfile.nt
i am then looping through each line using:
    while [ln: first d] [ ;do something here ]

i need to record the byte position of the start and end of each line...
how?
PeterWood
3-May-2012
[169]
I think you will have to calculate them yourself using length? ln 
and adjust for newline/cr as appropriiate.
Sujoy
3-May-2012
[170x3]
thanks Peter...

i can find the length? of each line, but how do i calculate the length 
of the newline?
>> length? to-string #"^/"
== 1
>> length? to-string crlf
== 2
how do i detect the newline used in %bigfile.nt?
Maxim
3-May-2012
[173]
hahaha I was writing exactly about this.
Sujoy
3-May-2012
[174]
:)
Maxim
3-May-2012
[175x2]
basically... just find crlf in the file.
if you find one, you can assume its using crlf format for newlines.
Sujoy
3-May-2012
[177x2]
ok...
trying that now...
p.s.: any luck with the new mod-api release?
Maxim
3-May-2012
[179x2]
you can always try using /binary, but I don't know how it relates 
to using /lines.  IMO if you use /lines, the /binary refinement doesn't 
make a lot of sense
wrt mod-api... yes, and no, I was temporarily assigned to another 
project, but should get back to it tomorow, so I hope to have a release 
next week.
PeterWood
3-May-2012
[181x2]
how do i detect the newline used in %bigfile.nt?

 - you can read the first line from the port to work out it's length 
 and then read the fiirst line + the two subsequent bytes in binary 
 mode to check whether they are lf + first char of second line or 
 cr +lf.
This might help you get started:

>> d: open/direct/lines %system-use-case-list.html
>> ln-d: length? ln: first d
== 6
>> ln+nl: read/binary/part %system-use-case-list.html ln-d + 2
== #{3C68746D6C3E0D0A}
Sujoy
3-May-2012
[183x3]
cool - look forward to it maxim
thanks Peter
not sure i've got it though
>> p: open/direct/lines %benchmark_250k.nt
>> ln-d: length? ln: first p
== 195
>> ln+nl: read/binary/part %benchmark_250k.nt ln-d + 2
== #{
3C687474703A2F2F777777342E7769776973732E66752D6265726C696E2E6465
2F62697A65722F6273626D2F7630312F696E7374616E6365732F50726F64...
>> print to-string ln+nl

<http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType1>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#t

ype> <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/ProductType>
.
<
so there is a newline + the first character of the next line
PeterWood
3-May-2012
[186]
To visually check better to print the binary ie
	print ln+nl
Sujoy
3-May-2012
[187]
if i do this:

>> length? find ln+nl newline
== 2


...but how do i detect that the newline in this case has length 1?
PeterWood
3-May-2012
[188]
Something like this should work:

>> ;; position at 2nd last char of ln+nl
>> ln+nl: back back tail ln+nl
== #{0D0A}
>> ;; see if the first of the two chars is a linefeed
>> either #"^(0a)" = first ln+nl [size-nl: 1] [size-nl: 2]
== 2
Sujoy
3-May-2012
[189x2]
super!! Thanks Peter!
just so i remember:
>> print to-binary cr
#{0D}
>> print to-binary crlf
#{0D0A}
>> print to-binary lf
#{0A}
Kaj
3-May-2012
[191]
Watch out for text files that are edited on Windows and other systems 
and end up mixing different newlines
Sujoy
3-May-2012
[192x2]
I was just cracking my head over that Kaj...
will have to look for another way i guess :(
Kaj
4-May-2012
[194x2]
It can still be done, but you have to look for all possible newline 
combinations
If you can control your environment, you could mandate an editor 
that does automatic conversion
GiuseppeC
6-May-2012
[196]
where I am wrong ?

I have an object called news
news/tittle: "Something"
news/data: 06-may-2012

I want to display these data using VID

view layout [
	h2  news/tittle
	h2  news/date
]

news/tittle is displayed
news/date is not

Where I am wrong ?
Henrik
6-May-2012
[197x2]
I have an object called news
news/tittle: "Something"
news/data: 06-may-2012

you did not use /DATA as a typo?
also, it may be that H2 does not support dates as input
GiuseppeC
6-May-2012
[199x5]
yes, it is a Typo
to-string news/date solves the problem
txt does not support DATES too
Another question from a newcomer to VID:
How do I refresh the window with new data without closing it ?
Henrik
6-May-2012
[204x2]
First, assign words to your texts:

view layout [
	t1: h2
	t2: h2
]

Then create a function to update the content:

update-texts: func [tt1 tt2] [
	t1/text: tt1 ; not sure that SET-FACE works here.
	t2/text: tt2
	show [t1 t2]
]

Then use the function where you need it.
You may need to give both faces an initial width, otherwise the text 
won't fit.
Endo
7-May-2012
[206]
Or give a name to your window:
view lay: layout [...]

and call "show lay" when you make changes. This will refresh the 
whole widgets in the window.

It's better to refresh what you've updated, not the whole window, 
as it is much more slower. But when you are testing it is easier.
Henrik
7-May-2012
[207]
This is only partly true.


It is in fact faster to SHOW the whole window, rather than calling 
SHOW multiple times for single elements, when there are sufficiently 
many elements in the window. Still, SHOW also depends on the size 
of the area to display, so if you have, say 10 fields, wrap them 
in a PANEL style and then perform the SHOW on the PANEL instead of 
the whole window or the individual fields.
Endo
7-May-2012
[208]
That's right. What I meant was SHOWing the whole window when you 
need to refresh one element, is slower. Otherwise it depends on how 
many items refreshed/updated etc.

It is easier to SHOW the whole window for beginners because they 
usually forget to SHOW the item they've updated.
GiuseppeC
7-May-2012
[209x2]
Isn't in VID a god text viewever with scrollers ? Text List does 
not work here. It show only the first line of text.
*good