World: r4wp
[Rebol School] REBOL School
older newer | first last |
Endo 15-May-2013 [1993] | Gregg: When use /REVERSE refinement it searches backwards from the current position. So I expect to find the /last "o" (in the negative direction) which is "oboco". aOboco the captial O is the LAST one in backward direction. I understand that the last "o" is still the right most one. But I expected the other one at first glance. |
Gregg 15-May-2013 [1994] | Understood. That would make it redundant with /REVERSE, rather than overriding it. |
DideC 17-May-2013 [1995x2] | To my understanding "find/last serie value" is the same thing than "find/reverse tail serie value". |
But it found the first value backward from the position, so "o" is correct result. | |
Endo 23-May-2013 [1997x2] | Which script do you suggest me to use for parsing XML files for R'? There are many on rebol.org. I mainly want XML to object, so I can export data from .xlsx file. XML to blocks might work but I may need to work on objects for more functionality. |
* for R2 | |
Geomol 23-May-2013 [1999x2] | If I remember correctly, you can't go 1 to 1 from xml to object. You can to block. I've only used my xml2rebxml.r, which produces a block. You could work from there, pull out the elements, you need, and produce an object. http://www.rebol.org/view-script.r?script=xml2rebxml.r |
The RebXML format is described here: http://www.fys.ku.dk/~niclasen/rebxml/rebxml-spec.html | |
Endo 23-May-2013 [2001] | Thank you Geomol. I saw AltXML from Christopher Ross-Gill, I'll try both. Thanks. |
Endo 27-May-2013 [2002x2] | Chris: is that normal? >> load-xml {<si><t xml:space="preserve">test</t></si>} == [ <si> [ <t> [ #space "preserve" %.txt "test" ] ] ] |
Why it puts %.txt ? | |
GrahamC 27-May-2013 [2004] | Chris is in Peru at present .. don't expect any answers soon. Unless you talk to him on SO chat |
Maxim 27-May-2013 [2005] | for sure, you want stuff to be tag pair aligned so you can easily loop through it... though I don't know why he uses the file type to mark tag content. probably just to differentiate it from attribute and tags |
AdrianS 27-May-2013 [2006] | Endo, that's just his notation for a text node - not meant to imply it's a file. |
Endo 28-May-2013 [2007x2] | I see, I just confused if it's a bug or not. >> load-xml {<a>test</a>} ; == [ <a> "test" ] >> load-xml {<a b="c">test</a>} ; == [ <a> [ #b "c" %.txt "test" ] ] |
Why this doesn't work? >> parse [1] [1] ;== false while this one works >> parse [a] ['a] ; == true | |
Cyphre 28-May-2013 [2009] | parse uses literal numbers for rules definition you need to use: parse [1][integer! (process-integer-here)] |
Endo 28-May-2013 [2010] | So, no chance to specify an exact number in a parse rule? |
Geomol 28-May-2013 [2011] | >> parse [1] [1 1 1] == true >> parse [1 1] [2 2 1] == true |
Maxim 28-May-2013 [2012] | darn... never new we could do that!!!! logical enough... wonder why I never tried it. |
Andreas 28-May-2013 [2013] | In R3, youi can also use the QUOTE command: >> parse [1] [quote 1] == true |
Gregg 28-May-2013 [2014x3] | parse-int-values: func [ "Parses and returns integer values, each <n> chars long in a string." input [any-string!] spec [block!] "Dialected block of commands: <n>, skip <n>, done, char, or string" /local gen'd-rules ; generated rules result ; what we return to the caller emit emit-data-rule emit-skip-rule emit-literal-rule emit-data digit= n= literal= int-rule= skip-rule= literal-rule= done= build-rule= data-rule skip-rule ][ ; This is where we put the rules we build; our gernated parse rules. gen'd-rules: copy [] ; This is where we put the integer results result: copy [] ; helper functions emit: func [rule n] [append gen'd-rules replace copy rule 'n n] emit-data-rule: func [n] [emit data-rule n] emit-skip-rule: func [n] [emit skip-rule n] emit-literal-rule: func [value] [append gen'd-rules value] emit-data: does [append result to integer! =chars] ; Rule templates; used to generate rules ;data-rule: [copy =chars n digit= (append result to integer! =chars)] data-rule: [copy =chars n digit= (emit-data)] skip-rule: [n skip] ; helper parse rules digit=: charset [#"0" - #"9"] n=: [set n integer!] literal=: [set lit-val [char! | any-string!]] ; Rule generation helper parse rules int-rule=: [n= (emit-data-rule n)] skip-rule=: ['skip n= (emit-skip-rule n)] literal-rule=: [literal= (emit-literal-rule lit-val)] done=: ['done (append gen'd-rules [to end])] ; This generates the parse rules used against the input build-rule=: [some [skip-rule= | int-rule= | literal-rule=] opt done=] ; We parse the spec they give us, and use that to generate the ; parse rules used against the actual input. If the spec parse ; fails, we return none (maybe we should throw an error though); ; if the data parse fails, we return false; otherwise they get ; back a block of integers. Have to decide what to do if they ; give us negative numbers as well. either parse spec build-rule= [ either parse input gen'd-rules [result] [false] ] [none] ] |
>> parse-int-values "123456" [1 2 3] == [1 23 456] | |
Just as an example of how you can work around it with a bit of indirection. | |
Sujoy 7-Jun-2013 [2017] | this is on r3 am trying to do a simple read http://google.com and get Access error: protocol error: "Redirect to other host - requires custom handling." how do i custom handle? |
Endo 7-Jun-2013 [2018] | I think you should use cURL binding for R3. |
GrahamC 7-Jun-2013 [2019x3] | @Sujoy .. there some relatively easy fixes to the R3 http protocol to handle this. But .. due to various issues .. they just have not found their way into the binaries :( |
Basically the http protocol sees a redirect eg. from http:// google to https google and complains. | |
or from google.com to www.google.com etc. | |
Sujoy 7-Jun-2013 [2022x3] | thanks graham. endo - looking at cURL...thanks for the pointer |
>> import %./cURL-binding.so ** access error: cannot open: %./cURL-binding.so reason: "not found or not valid" | |
any ideas why? i'm on a amazon linux instance... | |
GrahamC 7-Jun-2013 [2025] | Have you installed all the libraries required for cURL? |
Sujoy 7-Jun-2013 [2026x2] | i think so graham - did a yum install curl |
and i can curl http://google.comfine | |
GrahamC 7-Jun-2013 [2028] | Guess have to ask Kaj then ... I tried this before and worked fine for me |
Sujoy 7-Jun-2013 [2029] | thanks graham...hoping kaj will see this... |
Endo 7-Jun-2013 [2030] | Here you can find some info: http://rebol.esperconsultancy.nl/extensions/cURL/ |
Kees 17-Jul-2013 [2031] | Question about an example from the R3 docs: str: "abcdef" end: find str "d" for s str end 1 [print s] abcdef bcdef cdef def find finds the d at position 4, if I replace end with 4, I get the same result. However: type? end says string! and no pointer If I replace the text in str, end still equals to "def", so it does not point at str any more. Can someone explane this? |
Pekr 17-Jul-2013 [2032x2] | 'find returns the string at certain position, just print 'end, and you will obtain "def" |
your 'for construction looks strange, I am wondering it works :-) | |
Kees 17-Jul-2013 [2034] | It does, both in R2 as in R3, this is from http://www.rebol.com/r3/docs/guide/code-loops.html#section-3 |
DideC 17-Jul-2013 [2035x4] | In Rebol, there is no "pointer" (C like). string!, binary! are series. Series are groups of elements (character, octet) so a word! (like str or end) associated to a serie hold also a position on it. |
You can mak as many sords you want pointing to the same serie at the same or different position. | |
mak=make sords=words (sory) | |
Understanding your cade form the interpreter point o view : | |
Kees 17-Jul-2013 [2039] | How can I find out that the for loop exchanges end with 4, exept for looking it up myself ? |
DideC 17-Jul-2013 [2040] | str: "abcdef" ==> Create a string! in memory, put "abcdef" as its content, create a word! 'str an make it point to its head. |
Pekr 17-Jul-2013 [2041x2] | hmm, I just tried for i 1 str 1, and it screams ... but maybe if given the same type, a string for e.g., maybe it takes their index value? |
>> index? str == 1 >> index? end == 4 | |
older newer | first last |