World: r3wp
[Core] Discuss core issues
older newer | first last |
Pekr 16-Jul-2009 [14234] | call/output does not work, when console is not being run? I tried to convert some character sets, prepared short script, and run it by double-clicking .r file. No result was shown and rebol process is hang in memory. It was enough to put one print statement so that console showed up, and it was OK then. But that is weird, I wanted it to run without REBOL console showing up ... |
Gregg 16-Jul-2009 [14235] | Yes, that's a known issue. |
Graham 20-Jul-2009 [14236x3] | What happened to the open/async ? |
as per http://www.rebol.net/docs/async-examples.html | |
I read somewhere that if you do any other IO during async, that will break the async. True?? | |
Maarten 20-Jul-2009 [14239] | Within an async handler things might get unpredictable. If you have a normal event loop, including async in the wait-list, I think you should be good. |
Graham 20-Jul-2009 [14240x3] | I was wondering how to download a 120Mb file from S3 |
and wanting to do it async while write/binary/append in the async handler | |
was open/async removed after 2.5.5 ?? | |
Maarten 20-Jul-2009 [14243x2] | Yes. |
It interfered with the garbage collector and was one of the reasons to start R3 development iirc (the whole port subsystem, actually). | |
Pekr 20-Jul-2009 [14245x3] | Graham - you don't need the async mode in order to behave in an async like manner ... |
I can send you short script called "multiserver", which is able to accept connections from various IPs, save content to file, it simply multiplexes on opened ports .... | |
the script is very short, commented. It served as example for my friend learning REBOL. | |
Graham 20-Jul-2009 [14248x2] | That's okay Pekr ... I was just trying to see if I could use the style as written by Carl. |
Maarten ... when did that become common knowledge?? I had endless issues trying to upload files async, and it only worked by turning off GC .... but of course killed my program with huge memory use :( | |
Ashley 20-Jul-2009 [14250x2] | Anyone have a nifty func to "untrim" a string? Something that converts: "ArialBold" to: "Arial Bold" Best I can come up with is a horrible replace loop: foreach char "ABC ..." [ replace/all next string char join " " char ] replace/all string " " " " ; handle case where words were already space seperated |
replace/all next -> replace/all/case next | |
Graham 20-Jul-2009 [14252] | you want to insert spaces before each caps ? |
Ashley 20-Jul-2009 [14253] | Yep |
Graham 20-Jul-2009 [14254] | can't you use parse |
Ashley 20-Jul-2009 [14255] | One of the few things I've yet to master in REBOL! ;) |
Graham 20-Jul-2009 [14256x3] | caps: charset [ #"A" - #"Z" ] non-caps: complement caps parse "ArialBold" [ some [ copy fontname name (print fontname) ]] |
>> parse "ArialBold" [ some [ copy fontname name (repend out [ fontname " " ]) ]] == true >> out == "Arial Bold " | |
close enuf ?? | |
Ashley 20-Jul-2009 [14259] | ** Script Error: name has no value |
Graham 20-Jul-2009 [14260x2] | name: [ caps some non-caps ] out: "" |
cut and paste works poorly in windows :( | |
Ashley 20-Jul-2009 [14262x2] | and Mac ... |
Thanks, that's enough for me to start with. | |
Graham 20-Jul-2009 [14264] | >> parse next s: "ArialBoldItalic" [ some [ some non-caps [ end | mark: ( insert mark #" " ) skip ]] ] == true >> s == "Arial Bold Italic" |
Ashley 20-Jul-2009 [14265] | Even better! |
Graham 20-Jul-2009 [14266] | I'm waiting now for Ladislav's answer ! |
Ashley 20-Jul-2009 [14267] | In 12 bytes or less ;) |
Pekr 20-Jul-2009 [14268] | not sure if correct, but: caps: charset [ #"A" - #"Z" ] non-caps: complement caps s: "aaaArialBoldItalic" parse/all s [any [mark: caps (insert mark #" ") skip | skip] end] |
Ashley 20-Jul-2009 [14269] | Slight complexity, "HelveticaCY" has to parse as "Helvetica CY" not "Helvetica C Y" |
Graham 20-Jul-2009 [14270x4] | >> parse next s: "ArialBoldItalicYY" [ some [ some non-caps [ end | mark: ( insert mark #" " ) 2 skip ]] ] == true >> s == "Arial Bold Italic YY" |
>> parse/all s: "abcArialBoldItalicsCY" [some [mark: caps (insert mark #" ") 2 skip | skip] end] == true >> s == "abc Arial Bold Italics CY" | |
I think you should have 'some and not 'any as there should always be at least one space to be inserted. | |
Pekr's rule looks shorter because you don't need the non-caps | |
Ashley 20-Jul-2009 [14274] | 'some works. The 4 variations it has to handle are: "Arial" "ArialBold" "ArialBoldItalic" "ArialCY" so putting a 'next prior to 's seems to handle all these. |
Pekr 20-Jul-2009 [14275x2] | 'any will work too ... |
putting 'next there serves the purpose, but is an ugly hack :-) | |
Graham 20-Jul-2009 [14277] | why is it a hack?? |
Pekr 20-Jul-2009 [14278] | you should solve it by parse and parse only - that is the challenge :-) |
Graham 20-Jul-2009 [14279x2] | we know we only have to parse part of the string ... not all of it |
I find it easier to bypass edge conditions rather than program for them :) | |
Ashley 20-Jul-2009 [14281x2] | I'm with G on this one. |
Here's the finished code (which obtains REBOL compatable font names under Mac): fonts: copy [] caps: make bitset! [#"A" - #"Z"] foreach file compose [(read %/System/Library/Fonts/) (read %/Library/Fonts/)] [ if %.dfont = suffix? file [ s: form first parse file "." parse next s [any [mark: caps (insert mark #" ") 2 skip | skip] end] insert tail fonts s ] ] remove-each font-name fonts: sort unique fonts [ (size-text make face [text: "A" font: make face/font [name: font-name size: 10]]) = size-text make face [text: "A" font: make face/font [name: font-name size: 12]] ] (the windows func to do this is http://www.reboltech.com/library/scripts/get-fonts-windows.r ) | |
Pekr 20-Jul-2009 [14283] | there's no edge condition. What if the name would not begin with a capital letter? I would parse all string and instead of 'next I would use 'trim, which would tream initial space, in case first letter is capital :-) But if it is the rule, that the first letter is always being a capital, then your solution is absolutly correct ... |
older newer | first last |