World: r4wp
[Rebol School] REBOL School
older newer | first last |
Sujoy 7-Jun-2013 [2027] | 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 [2041x3] | 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 | |
you should know, that 'end is just a reference to still the same str, which can be proven, by inserting new element into str .... | |
Kees 17-Jul-2013 [2044] | Yes, index? does it! Thanks Pekr |
DideC 17-Jul-2013 [2045] | end: find str "d" ==> search for "d" in the "abcdef" series in memory, then create a word! 'end that hold the position of "d" in this same serie. |
Pekr 17-Jul-2013 [2046] | >> insert str "0" == "abcdef" >> str == "0abcdef" >> end == "cdef" |
DideC 17-Jul-2013 [2047] | so 'str and 'end just hold different position in a unique string! |
Pekr 17-Jul-2013 [2048] | good point, DideC |
Kees 17-Jul-2013 [2049] | Tried that myself, but no change in end, which Rebol version are you using? |
DideC 17-Jul-2013 [2050] | Then, the 'for loop can work as it's positions in a unique serie! |
Pekr 17-Jul-2013 [2051x3] | 2.7.8 |
Kees - beware - rebol series concept needs really carefull aproach - it caused me a headache when working with series, till I became accustomed to it. And still, sometimes, I use trial and error aproach in console ... | |
Kees - better start with a fresh session, fresh series .... | |
DideC 17-Jul-2013 [2054] | If I replace the text in str, end still equals to def", so it does not point at str any more." How do you replace the text in 'str ? If it's like this: str: "new text" then you have created a new string! in memory and point 'str to this new serie. 'str and 'end does not point anymore the same string! |
Pekr 17-Jul-2013 [2055x3] | try on one line in console: >> str: "abcdef" end: find str "d" print end insert str "0" print end def cdef |
Kees: there are 'replace and 'change functions .... | |
or: >> str/3: #"1" == #"1" >> str == "0a1cdef" | |
DideC 17-Jul-2013 [2058] | to change the content of the "abcdef" string! you create in first place you have to change it in some way. Pekr used 'insert to add a character in the begining. You can change all its content like this: insert clear str "new content" then probe end give " content" So we have acted on the same string in memory. |
Kees 17-Jul-2013 [2059x2] | Yes I see that now |
Thank you both! | |
DideC 17-Jul-2013 [2061] | You may read the series page http://www.rebol.com/docs/core23/rebolcore-6.html |
Kees 17-Jul-2013 [2062] | Thanks DideC, I will |
Pekr 17-Jul-2013 [2063] | Yes, that chapter is kind of ... essential imo :-) |
Geomol 17-Jul-2013 [2064] | If the two words represent the same string (but different position), then this will return true: >> same? head str head end == true |
DideC 17-Jul-2013 [2065] | The key with series programming in Rebol is always "Is this the same serie or a new one ?" Sometimes you want to act on the same. sometimes you want to act on another. FUNDAMENTAL |
Ladislav 17-Jul-2013 [2066x4] | #[[DIdeC str: "abcdef" ==> Create a string! in memory, put "abcdef" as its content, create a word! 'str an make it point to its head. ]] - that is not true, in fact. The proper description is as follows: str: "abcdef" is a Rebol source (or a part of it). That source is first processed by LOAD. LOAD creates the Rebol value representing "abcdef". Also, LOAD does *not* set the 'str value (yet). Later on, when the DO function evaluates the (already LOAD-ed code), it just makes the 'str variable to refer to the string value not creating anything at all (this difference is crucial). |
Dide, you should make sure you understand this difference. | |
There is even a possibility to write: end: #[string! "abcdef" 4] | |
I can give you a similar description as above even for this case, if you like. | |
DideC 17-Jul-2013 [2070] | Yes you are right. |
Endo 18-Jul-2013 [2071] | Ladislav: "this difference is crucial" Could you please explain why this difference is important? Or better why it is important to understand? I understand there is a big difference, but why it is important to know? |
Ladislav 18-Jul-2013 [2072] | Endo, you may know this case: my-code: [s: "" append s #"x"] do my-code do my-code ; == "xx" my explanation is accurate for this case as well. You can see that the string (the "" value following the s: set-word) was created by LOAD only once, while append occurred twice expanding the string to contain "xx". |
Endo 18-Jul-2013 [2073] | created by *LOAD* only once , Ok I got it now. Thanks for the explanation. |
Janko 18-Jul-2013 [2074x2] | I have a question about timezones. I need to make a selector for workonomic where user can set the TimeZone Like "Europe/Ljubljana" instead of TZ offset which changes between summer/winter time depending on the timezone etc.. |
I assume rebol doesn't have "Labeled Timezon => current offset" capability so I am wondering if anybody had to do this and what (s)he found the best solution was? I see two ways, using external service in a lang that has such database/library (like php's ) or using the OS below (from bash) "TZ=":Pacific/Auckland" ; date +%z" ... also is there anything still I can do inside rebol, like getting some prefilled sqlite db using some lib I don't know of.. | |
Gregg 18-Jul-2013 [2076] | QTask may have solved this, and the source should be available somewhere. It might have been Bolek that worked on it, but I can't remember. |
older newer | first last |