[Rebol School] REBOL School
here is a simple way to get the code for a face within the layout function ( I found it the easiest to remember): view layout [ across text "1" my-radio: radio on do [probe my-radio] text "2" radio ] the advantage of this system is that you get the actual face with any facets setup as they really are in your gui. this is often the easiest way to identify just where and how a specific facet affects a face... probe it without your change, and then run it again, with your change... comparing both probes in a diff or merge tool.
the other way is to use get-style. the advantage here is that is preserves the init block, instead of clearing it after VID has done its work a good look at the 'init block is often useful to understand why changing some of the face values is ineffective (like changing face/color is often useles... since that face is setup to use face/colors). this block is run after all the facets have been applied. note that you can set or append to this block in your own styles.
get-radio-buttons: does [ reduce [ get-face option-1 get-face option-2 get-face option-3 ] ] reset-radio-buttons: does [ clear-face option-1 clear-face option-2 clear-face option-3 ] view layout [ option-1: radio-line "Option 1" of 'options [probe get-radio-buttons] option-2: radio-line "Option 2" of 'options [probe get-radio-buttons] option-3: radio-line "Option 3" of 'options [probe get-radio-buttons] btn "reset radios" [reset-radio-buttons] ]
Best to use the getter-/setter-methods wherever they are implemented.
anyone know which one of these would be the correct one to use? 1. percentile: func[s p /local n][n: round/floor (p * (length? s) + 0.5) return s/(n - 1)] 2. percentile: func[s p /local n][n: round/floor (p * (length? s) + 0.5) return s/(n)] - I cannot recommend any of them. (ROUND/FLOOR is not what is recommended in Wikipedia, also the percentile calculated this way is not compatible with the "standard median definition". I recommend to use interpolation on Hazen ranks as mentioned in Wikipedia under "interpolation", or on Mean ranks as recommended by NIST - also can be found in WP)
I have view.txt in my rebol/script folder a copy from system/view, it is 80000 lines mostly object definitions and images. quite different from the ancient one http://www.rebol.com/view/vid.rthat at least makes some sense to me ;-)
getter/setter is a nice theoretical concept, nice for OO purposes. Radio buttons of a group should function like this: always 1 selected, the default to begin with, each option should have a value that is copied to the radiogroup's /data field, so to know what was selected can be found just like that. Not more not less. rg: radiogroup rg1 radio on 'rg1 "Text 1" "A" radio 'rg1 "Text 2" "B" and in your program switch rg1/data [ A [do this] B [do that]]
Arnold, take a look at the VID Extension Kit. It attempts to make VID more complete, although it's no longer directly compatible with VID.
One thing to note about VID: It was a demo toolkit that Carl wrote about 10 years ago in a couple of weeks. He expected someone to come up with something better.
It is hard to beat in its simplicity. But also hard to improve in its current state. More a modular way would have been nicer. So it would have been clear where to start if you want to improve (or first find out) the behaviour of radio buttons for example.
Same thing as he expected the community to come up with the new bindings of REBOL3 to about all other Open Source operating Systems (Rebolution!) whereas the REBOL kernel source stays closed source. Not much animo since. Au contraire. Could have been the final nail...
Arnold, I came up with one solution to the radio question here: http://stackoverflow.com/questions/6401469/how-do-i-get-the-radio-button-value-in-rebol
It may be overkill, but it iterates through all faces looking for the 'of relationship, returning the selected face.
Hi Chris! Thank you. I consulted this site also. But there is better news to this! In stead of the words on and of you have to use the words true and false and the problems are solved! Didn't even have to initialize the /data fields between creating the layout and calling it in action with view. Not documented but stil possible. (Like it is also undocumented on the REBOL site that you can have a checkbox followed by an action block.And this is also possible on text-labels making them clickable and have an mouse-over effect.)
Today I experimented with calling a REBOL script from my php script. Thanks to previous contributions of a.o. Ralph Roberts of abooks.com from 1999(!) and an entry on the PHP site I found out how to do this on my apache driven site. It was not quite as straightforward as Robert said like: include ("rebolnow.r"); Nor was it as simple as: system("rebolnow.r 2>&1", $myout); echo $myout; But it worked when I called out for the REBOL program first. Both two of the next examples worked for me: system("/path/to/cgi-bin/rebol -c %rebolnow.r 2>&1", $myout); echo $myout; AND secondly echo system("/path/to/cgi-bin/rebol -c %rebolnow.r"); Work! The REBOL script must be in the same dir as your PHP script (Not in your cgi-bin directory)(I didn't test sub dirs and other dirs but I suppose they work like usual) The script does not need the #!/path/to/rebol line at the top. The script should not print http-headers and When printing stuff the last line should read print "" because the last printed line will be repeated. Hope this helps more people to switch from php scripting to REBOL scripting for their websites.
If you want to just echo the REBOL output, I would suggest using PHP's passthru() instead - it was designed for that: http://php.net/manual/en/function.passthru.php
This says it is for binary data like images. In the first lines of this post http://www.mail-archive.com/[list-:-rebol-:-com]/msg01452.html it is mentioned as bringing not the solution to this wish. I passed this by, I'll stil have a second look, things in php could have 'suffered' improvements..
Does anybody have any experience in controlling servo motors using REBOL through USB devices/ports?
isn't that sort of time-critical?
I'm not in a hurry?! :)
I think Henrik means that you can get bitten by REBOL hanging for short periods of time in the garbage collector
It is interacting with the real world, robotica, control engineering..
Then the garbage should be separatedly collected. The paper, the glass, the compostable material, heavy metal's and rest-garbage. :)
You can turn off garbage collecting and do it in the "coffee breaks", with this. recycle/off
With the 'large' programs I have in mind there will never be lots of garbage to collect. I don't know much/anything about robitics and control engineering by the way, I am interested in this because I realized using REBOL to do things like this could have large potential. And I want to move a little car with a photocamera and taking photo's from centain positions. The car may also be guided by a rail of some sort.
Domotica could also be a nice DSL.
PHP: I tried the passthru function. It worked, but I do not see any benefit from the exec function. I prefer exec over passthru. Saves typing, not that I do any. I always cut and paste code offcourse.
I meant system. exec didn't work. I still prefer system above passthru. I have integrated my first REBOL module within my website. I needed to add a cookie section to obey the new cookie law anyway. I even used a REBOL script to generate all cookie pictures to the same size and png format.
How can I get the error text when I use TRY, I want to show the original error text to the user: if error? set/any 'err try [1 / 0] [probe disarm err] I think I saw something similar in UniServe sources but couldn't find it.
This function should help you: form-error: func [err [object!]][ foreach w [arg1 arg2 arg3][ set w either unset? get/any in err w [none][ get/any in err w ] ] reform [ "***" system/error/(err/type)/type #":" reduce system/error/(err/type)/(err/id) newline "*** Where:" mold/flat get in err 'where newline "*** Near: " mold/flat get in err 'near newline ] ]
Great! Thanks a lot Doc.
this is my version: http://www.rebol.it/power-mezz/mezz/form-error.html note that it does not make arg1, arg2 and arg3 global.
I am busy with a little chess program. Just the board and the pieces to be moved on the board. (I have seen the examples on rebol.org). It is meant to be for a chess learning/training program and possibly demonstration/game review and maybe have a coupling with an open source chess engine like Stockfish.. I am going to write a little script to determine all possible legal moves. I want some information for what is an appropriate way to represent the board and moves in REBOL, for example the 8-bit white/black init-position king queen rook bisschop kNight pawn and board could be a1-h8 or an array of 64 elements or a block (of blocks) Suggestions welcome please. Tia.
In the script display-chess-board.r on rebol.org there is this part ;; counter is now an image - note the 'key effect ;; user to make the black in the image transparent. ;; ------------------------------------------------ counter: box 30x30 effect [key 0.0.0 oval] This does not work, when keyword merge is added the middle part is transparent when the tuple is replaced with an integer, but only the other way around or the oval is limiting the working of merge to the inside of the circle?
you must add merge to the begining of effects, when you want images to pass thru faces.
Yes I tried all variations [merge oval key 127] [merge key 0.0.0 oval] etc. I got a hole in the middle at some points but never the other way around like the comment mentions :(
The chess program I want to make give the moves of a piece like on the shredder site http://www.shredderchess.com/daily-chess-puzzle.html and it will have a minimal validation routine so my kids (and me too) can beat the machine.
(I got the images from this site now I mention it here)
Anyone want to have a try at this little puzzle? I have a working solution, but I am sure there is way more REBOLish way. I have two objects that each contain simple REBOL values (ie imagine they've just been created from some serialised data, so no recursive blocks or anything tricky): obj1: make object! [aaa: 1 bbb: "xx"] obj2: make object! [bbb: "XX" aaa: 1] All I want to do is confirm that they contain identical words and values under normal REBOL comparison rules -- so obj1 and obj2 should be treated as identical, while the next few are not identical to obj1 or obj2: obj3: make object! [bbb: "xx"] ;; no 'aaa word obj4: make object! [bbb: "XX" aaa: 1 ccc: 3] ;; extra word obj5: make object! [bbb: "XX" aaa: -1] ;; different 'aaa word value I am sure there is a simple one-line 'parse solution .... Isn't there always!? Thanks!
if you really want a one-liner ;-) all [ obj2: make obj1 obj2 (words-of obj1) = (words-of obj2) (values-of obj1) = ( values-of (make obj1 obj2)) ]
the only way the above can fail is if a word in obj1 is set to none and that word is missing in obj2
Two little questions. I have a block like [ 0 0 0 0 ]. When first 'declared' should I use a: [ 0 0 0 0 ] or a: copy [ 0 0 0 0 ]? (I know I should use copy when c: copy a). Second question when to use b: make block [ 0 0 0 0 ] in stead of just b: [ 0 0 0 0 ]??
(that should be: make block! )
Depends on how you intend to use it. If you declare a series without COPY or MAKE, it references the data in what you usually think of as your source code
This is one of the standard REBOL pitfalls. You can think of such data as a constant. If you change it anyway, you're changing the representation of your program code
So if you're not going to use the data as constant, use COPY or MAKE. For a block with scalar values in it, it doesn't make much difference
I make in init block b: [ 0 0 0 0 ] and use the c: copy b and d: copy b as variable block.