World: r3wp
[View] discuss view related issues
older newer | first last |
Louis 16-Oct-2006 [5816] | Please View experts come to my rescue! |
Sunanda 16-Oct-2006 [5817] | You could replace the clear-fields line with this line: Notes/text: copy "" show notes Thus just clearing the notes field rather than all fields. |
Graham 16-Oct-2006 [5818x4] | this includes a lot of redundant code |
either all [exists? %exchange-rate.txt "" <> read %exchange-rate.txt][ exchange-rat: read %exchange-rate.txt ][ write %exchange-rate.txt 1 exchange-rat: read %exchange-rate.txt ] | |
if not all [exists? %exchange-rate.txt "" <> exchange-rat: read %exchange-rate.txt][ write %exchange-rate.txt "1" exchange-rat: "1" ] | |
if not all [exists? %exchange-rate.txt "" <> exchange-rat: read %exchange-rate.txt][ write %exchange-rate.txt exchange-rat: "1" ] is a little shorter again | |
Louis 16-Oct-2006 [5822x7] | Sunanda and Graham, many thanks. Slowly but surely my script is better and better. The REBOL solution is almost always much easier than I thought. Thanks again! |
Ok, I have 61 out of 63 fields to clear, so it would be a lot easier to deal with those two that don't have to be cleared than to deal with the 61 that must be. So I propose a modification to the clear-fields function: Here is the source: clear-fields: func [ "Clear all text fields faces of a layout." panel [object!] ][ if not all [in panel 'type panel/type = 'face] [exit] unfocus foreach face panel/pane [ if all [series? face/text flag-face? face field] [ clear face/text face/line-list: none ] ] ] | |
I would just like to put the panes I don't want to be cleared into a block; all the rest would be cleared. | |
I think I can do this, but it would probably be better for you experts to come up with something really simple and elegant that can be submitted to RT for Rebol 3. | |
It is just logical that this function has such a refinement. | |
Oh, the source above is what needs to be modified, not my modification. The only reason I posted it is to show how simple it is, and therefore how easy it should be to add a refinement to it. | |
It would be logical to call the refinement /except: /except "Block of fields not to clear." | |
Louis 17-Oct-2006 [5829] | I''m working on this myself. My first question: How can evaluation be based on the name of a field, and thus not on the contents of the field? If the name of the field is this then do that. |
Sunanda 17-Oct-2006 [5830] | Does this do what you want? clear-fields: func [ "Clear all text fields faces of a layout." panel [object!] /except exceptions [block!] ][ if not all [in panel 'type panel/type = 'face] [exit] unfocus if not block? exceptions [exceptions: copy []] exceptions: reduce exceptions foreach face panel/pane [ if all [series? face/text flag-face? face field not find exceptions face] [ clear face/text face/line-list: none show face ] ] ] ;; test/ example l-o: layout [ a: field "A" b: field "B" c: field "C" button "clear c" [ clear-fields/except l-o [a b] ] button "clear a" [ clear-fields/except l-o [b c] ] ] unview/all view l-o |
Louis 17-Oct-2006 [5831x3] | Sunanda, thanks! That works perfectly. Your refinement made what would have been a big job into a minor task that took only a few seconds. In my opinion, this refinement definately needs to be in Rebol 3. I will make newbies much happier. |
What is the best way to submit this to RT? | |
By the way, Allen Kamp sent me the same refinement code as Sunanda. Thanks to you also, Allen! | |
Anton 18-Oct-2006 [5834] | Louis, just catching up with your post back on Monday, I wanted to say that it's a bit odd to use the FEEL to do init code. It's not really intended for that. A way to do custom init code is like this: layout [ field with [ append init [ ; custom init code here text: exchange-rat ] ] ] and in the above case, just setting the text facet, it simplifies to: layout [ field (exchange-rat) ] |
Louis 18-Oct-2006 [5835] | Thanks. I like things to be simple. By the way, I just looked at your styles gallery. Very nice, and gives me examples to do things I need to do. |
Henrik 18-Oct-2006 [5836x3] | anton, the style gallery still doesn't work. I get the same include errors as yesterday. |
http://www.lexicon.net/antonr/rebol/patch/ctx-text-next-field-patch.r <--- link is dead | |
which is one of the first includes | |
Louis 18-Oct-2006 [5839] | Henrik, change load-thru to load-thru/update in Anton's script. |
Henrik 18-Oct-2006 [5840] | that won't help when the script to be included can't be found on the server (404) |
Louis 18-Oct-2006 [5841x2] | I just downloaded it a few minutes ago. |
it = the included scripts | |
Henrik 18-Oct-2006 [5843x2] | >> probe disarm try [load http://www.lexicon.net/antonr/rebol/patch/ctx-text-next-field-patch.r] connecting to: www.lexicon.net make object! [ code: 800 type: 'user id: 'message arg1: {Error. Target url: http://www.lexicon.net/antonr/rebol/patch/ctx-text-next-field-patch.r could not be retrieved. Server response: HTTP/1.1 404 Not Found} arg2: none arg3: none near: [load http://www.lexicon.net/antonr/rebol/patch/ctx-text-next-field-patch.r] where: none ] just tested 10 seconds ago |
what does it say when you try that line? maybe it's a faulty proxy | |
Louis 18-Oct-2006 [5845] | Same error as you got. |
Henrik 18-Oct-2006 [5846] | ok, then the files are really gone |
Louis 18-Oct-2006 [5847] | >> exists? http://www.lexicon.net/antonr/rebol/patch/ctx-text-next-field-patch.r connecting to: www.lexicon.net == false Looks like it. |
Anton 18-Oct-2006 [5848x6] | Henrik, thanks for trying. I could go through the usual rigmarole of determining the error (which is quite apparent to me from the above error message. That's my old website, at Lexicon.) *But* I am proud to announce a new include system !! Give this a try: |
head clear find site: select load-thru http://www.rebol.net/reb/index.r [folder "Anton"] %index.r do do-thru/update/args site/do.r [update "gui/style-gallery.r"] | |
The above code should *always work*, providing that I am able to maintain my most current website address at rebol.net . | |
It should work first time. When all is downloaded and run, all the needed files should exist in your cache. If you are happy with the cached version, and want to run directly from the cache, replace the second line with this one: do do-thru/args site/do.r [cache-only "gui/style-gallery.r"] | |
That's not quite right !!! | |
Use this code to check for newer versions and update your cache: head clear find site: select load-thru/update http://www.rebol.net/reb/index.r [folder "Anton"] %index.r do do-thru/update/args site/do.r [update "gui/style-gallery.r"] Use the code below when you are happy with the cached files you have and want to do those only: head clear find site: select load-thru http://www.rebol.net/reb/index.r [folder "Anton"] %index.r do do-thru/args site/do.r [cache-only "gui/style-gallery.r"] | |
Henrik 18-Oct-2006 [5854] | now it works. :-) very nice, anton |
Sunanda 18-Oct-2006 [5855] | Louis <What is the best way to submit this to RT?> Add it as an enhancement request to Rambo: http://www.rebol.net/cgi-bin/rambo.r And thanks for testing the code -- glad it worked.......One enhancemnet suggestion: you may not need the individual "show face" lines if you have a show layout-name at the end. |
Graham 18-Oct-2006 [5856] | Anton, your styles are looking better and better! |
Anton 18-Oct-2006 [5857x3] | Thanks... now that people can actually see it. :) |
Well, it's now over four and a half years since I began with include systems. The first version of the old include system was 17-Feb-2002. | |
I had another one in between which I didn't release. I think I tried to do too much with that one and it got hard to debug. | |
Louis 19-Oct-2006 [5860] | Sunanda, it has been submitted to rambo. Thanks again! |
Graham 19-Oct-2006 [5861x2] | when working with Vid data structures .. it makes sense to me to perhaps to create functions that act on a vid widget to be associated with that widget |
So, if you have a complex large program, you can keep all the functions that act upon/with a widget's data all in one place. | |
Maxim 20-Oct-2006 [5863] | do you mean like creating a style and specifiying the with block? view layout [ style button button with [ print-lbl: func [][print self/text] ] button "do" [face/print-lbl] ] |
Anton 20-Oct-2006 [5864] | (don't need the "self/" by the way). |
Maxim 20-Oct-2006 [5865] | I know it was just to make it explicit. |
older newer | first last |