World: r4wp
[Rebol School] REBOL School
older newer | first last |
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 | |
james_nak 7-May-2012 [211] | Giuseppe, if it is textviewers that you are looking for, you may want to see Henrik's Vid Extention Kit. http://www.hmkdesign.dk/project.rsp?id=vid-ext-kit&page=info because if you are going to do anything slightly more complex than VID "text-list" you will find data-list much more powerful. BTW, what are you supplying as data in your text-list? |
Gregg 7-May-2012 [212] | The LIST style is very flexible for read-only displays, but more work. |
Arnold 7-May-2012 [213] | nearly 11000 lines, almost replacing VID |
Henrik 7-May-2012 [214] | The number of lines may go up or down at times. There is a lot of experimental code and some dead code in it. |
GiuseppeC 7-May-2012 [215] | I am supplying text coming from a web page which has been de-markupped. |
Arnold 7-May-2012 [216] | Just make sure you never get paid per line of code |
Henrik 7-May-2012 [217] | Never made a dime on it. |
Arnold 7-May-2012 [218] | Not many people can make a living programming REBOL. That's for the Chit chat section |
GiuseppeC 7-May-2012 [219x2] | Henrik, just looking to your code: |
t1/text: tt1 I read it: assign to the object member T1/ text the new value ? Where is this documented ? I whish to learn more. | |
Henrik 7-May-2012 [221x2] | A face is an object, so this is no different than saying: a: make object! [text: "foo"] a/text: "boo" |
A problem with VID is that there is not a true standard way to set texts in various styles, so each style may either use /TEXT (which is IMHO the wrong way) or SET-FACE (which IMHO is the right way). | |
GiuseppeC 7-May-2012 [223] | An what about updating an image ? |
Henrik 7-May-2012 [224] | Then you access /IMAGE. |
older newer | first last |