World: r3wp
[Rebol School] Rebol School
older newer | first last |
Maxim 14-Feb-2011 [3407x2] | sunanda, that is a hell of a nice cheat! never thought of that one. |
pity it can't be made into a function :-) | |
Gabriele 15-Feb-2011 [3409] | that is not the current context, rather, the current "function name". (and Max... I think I posted that a long time ago ;) I was using it in my profiler) Awi, the thing is that functions don't have names. Also, by "context" in REBOL we mean something closer to what other languages call "frame", however REBOL has no concept of a "current frame" or of a "parent frame". R3 though has (had?) a STACK function that will probably give you want you want. |
BrianH 15-Feb-2011 [3410x2] | You can get the name of the word that the function was called through in the current call stack. This isn't *the* name of the function, but it's *a* name of the function. Note: "pity it can't be made into a function :-)" This is because if you put that trick in a function, then *that* function is the function that will be referenced. |
R3's STACK returns information about the entire call stack, though the 'debug security setting would put some limits on it. SECURE is disabled in recent builds so we don't know what the limits are; we could try older versions to find out what those limits used to be. Also, see http://issue.cc/r3/885for a bug in STACK. | |
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 [3456] | In R2, integers are 32 bit, in R3 64 bit. |
older newer | first last |