World: r3wp
[Rebol School] Rebol School
older newer | first last |
Awi 17-Feb-2011 [3412] | Thank you guys, I can never learn enough of Rebol. |
WuJian 7-Mar-2011 [3413] | >> a: "1. " ;here's a space == "1. " >> layout [text a] >> a == "1." |
Ladislav 7-Mar-2011 [3414x2] | That looks more like a quirk of the function, than as something one should explain to the beginners. |
The function looks like trying to be "cleverer" than the user. | |
WuJian 7-Mar-2011 [3416] | I feel that 'a should not be modified? |
Oldes 7-Mar-2011 [3417x3] | probe select system/view/vid/vid-styles 'text ... if all [not flag-face? self as-is string? text] [trim/lines text] ... |
Just don't know how one should set the flag as-is... I'm not using view many years | |
Googled.... >> a: "1. " layout [text as-is a] a == "1. " | |
WuJian 7-Mar-2011 [3420x2] | Ok |
[trim/lines text] or [trim/lines copy text] ? | |
Henrik 7-Mar-2011 [3422] | the latter one, if you don't want the original string modified. |
Janko 7-Mar-2011 [3423x2] | 0MQ binding.. that is awesome! Does/will this work for R2 also maybe? :) |
ups .. wrong chanel | |
Awi 9-Mar-2011 [3425] | VID question (R2): Is it possible to get the cursor position in the scroll-line event? I wanted to use the scroll to zoom in (like in google maps), and to zoom in to the right area, I needed the cursor position. Thanks for the help. |
Rebolek 9-Mar-2011 [3426] | You can get cursor position using CARET-TO-OFFSET |
Awi 9-Mar-2011 [3427] | Unluckily the face I am using is a plain panel, so no text there. I just tried PRINT CARET-TO-OFFSET pnl-map "", and it returns none. |
BrianH 9-Mar-2011 [3428] | That's the mouse pointer, not the cursor (sorry, terminology isn't very portable to REBOL). |
Gregg 9-Mar-2011 [3429] | You probably need to remember the offset from the last 'move event, since the scroll-line uses the event offset parameter itself. |
Maxim 9-Mar-2011 [3430x2] | yes, you need to hack the event engine a little bit. As gregg says, you need to have a memory of the last move event to get its position and store it (you can do this with an event-handler). glayout and GLASS do this for handling scrollwheel events. what I also do is find the top-level face which is under the mouse-cursor and fire off my own events from the scroll-wheel instead of relying on a text field. again, you can trap the scroll-wheel events in the event handler. if you want to have a ready-made solution, download glayout.r from rebol.org and look at the hacked WAKE-EVENT function. it already does all of this and wraps it up by adding new function you can add to your face/feel object in order to handle scroll-wheels. |
the wake-event function needs a few other functions which are all in the glayout module, but it should be easy to keep just what you need and run that before the rest of your script. | |
Awi 10-Mar-2011 [3432] | Thanks for the help, I am still digging around, will let you know the result. I will have to translate all that to RebGui though. |
Awi 28-Mar-2011 [3433] | Is there a better way than this to convert a block to string, then back to block? blk-to-send: reduce ['my-function 1 2 3] str-zmq: mold blk-to-send blk-received: first to-block str-zmq Thanks for the help! |
Rebolek 28-Mar-2011 [3434] | use LOAD instead of FIRST TO-BLOCK |
Awi 28-Mar-2011 [3435] | Thanks Rebolek! |
florin 14-May-2011 [3436] | Is there a way to start the word browser directly without going thru the viewtop? |
Geomol 14-May-2011 [3437] | do http://www.rebol.com/view/tools/word-browser.r You can <alt>-click (or right-click) icons in the viewtop to see, where the script come from. |
florin 14-May-2011 [3438] | Awesome |
Awi 30-May-2011 [3439] | Is there a way to to get the time in a datetime value without using refinement? >> d: now >> d/time == 12:09:58 Is there something like select d 'time OR pick d 'time ? Thanks. |
PeterWood 30-May-2011 [3440x2] | >> fourth now == 13:23:31 |
Works in both REBOL 2 and 3. | |
Sunanda 30-May-2011 [3442] | This works in R3: >> pick now 'date == 30-May-2011 |
Awi 30-May-2011 [3443x2] | This is cool! Thanks! |
I encountered another problem: >> 1.48297457491612E-2 + 0.985170254250839 == 1.0 >> arccosine/radians 1.48297457491612E-2 + 0.985170254250839 ** Math Error: Math or number overflow ** Near: arccosine/radians 1.48297457491612E-2 + 0.985170254250839 >> arccosine/radians probe (1.48297457491612E-2 + 0.985170254250839) 1.0 ** Math Error: Math or number overflow ** Near: arccosine/radians probe (1.48297457491612E-2 + 0.985170254250839) >> arccosine/radians 1.0 == 0.0 | |
Geomol 30-May-2011 [3445] | That's a rounding problem. You can check such numbers in R3 by: >> to binary! 1.48297457491612E-2 + 0.985170254250839 == #{3FF0000000000001} >> to binary! 1.0 == #{3FF0000000000000} |
Awi 30-May-2011 [3446] | I don't understand it, from 'probe', it seems like it already returned 1.0, why arcosine/radians still get > 1.0 |
Geomol 30-May-2011 [3447] | >> system/options/decimal-digits: 17 >> to decimal! #{3FF0000000000001} == 1.0000000000000002 |
Awi 30-May-2011 [3448] | >> (1.48297457491612E-2 + 0.985170254250839) = 1.0 == true |
Geomol 30-May-2011 [3449x3] | decimal-digits tell, how many digits, you wanna see. But when you're out there at 15-17 digits, you can't count on the last one, so it's choosen to be not seen. |
= (or equal?) is not exact. Use == (strict-equal?) >> (1.48297457491612E-2 + 0.985170254250839) == 1.0 == false | |
Makes sense? | |
Awi 30-May-2011 [3452] | Ok, I got it now. Thanks Geomol! |
Geomol 30-May-2011 [3453] | welcome |
Awi 30-May-2011 [3454x2] | Is there a best practice for such situation? Always rounding to 0.0000000000000001 ? |
well, I just tried (R2): >> (1.48297457491612E-2 + 0.985170254250839) == 1.0 == true | |
Geomol 30-May-2011 [3456x4] | In R2, integers are 32 bit, in R3 64 bit. |
sorry, 1 second :) | |
Hm, you may have a serious problem. Let me see... | |
:) REBOL2 can't do math. Thinking, if a struct! can help. | |
Awi 30-May-2011 [3460x2] | Hahaha :) |
>> arccosine/radians probe round/to (1.48297457491612E-2 + 0.985170254250839) 1E-15 1.0 ** Math Error: Math or number overflow ** Near: arccosine/radians probe round/to (1.48297457491612E-2 + 0.985170254250839) 1E-15 >> arccosine/radians probe round/to (1.48297457491612E-2 + 0.985170254250839) 1E-14 1.0 == 0.0 | |
older newer | first last |