AltME groups: search
Help · search scripts · search articles · search mailing listresults summary
world | hits |
r4wp | 43 |
r3wp | 377 |
total: | 420 |
results window for this page: [start: 1 end: 100]
world-name: r4wp
Group: #Red ... Red language group [web-public] | ||
DocKimbel: 10-Apr-2013 | Also, when asking for the file to be downloaded, you should rename the file to something more human-friendly or ask the name from the user. You can use Content-Disposition HTTP field for doing that easily. Here's an example from one of CureCode's RSP: response/buffer: get-modes file 'full-path response/set-header 'Content-Disposition rejoin [{filename="} name {"}] | |
Marco: 28-Apr-2013 | I'd like to know what your development environment for Red/System is especially that used by Doc. In the meantime... My development environment: OS: Windows 7 Editor: Notepad++ v5.0.3 not the latest version but I prefer this one, using "Python" as the language for syntax highlithing and coloring (there is not a "REBOL" language) and used mainly for the folding on indentation (I can not live without folding, and folding on indentation makes life even easier) I have added a menu item with a keybord shortcut to run REBOL with the currently shown file as argument. I have added also a menu item with a keybord shortcut to run my modified version of REBOL-Word-Browser At the end of the r/s file I add these lines (mostly taken from Bruno Anselme): #if OS = '???? [{ REBOL [] appname: "myprog" rs-dir: %../Red-master-0.3.2_Bruno/red-system ; locate here your red-system directory dest: rejoin [what-dir appname ] print [ "------ Compiling" appname "------" ] do/args rs-dir/rsc.r rejoin ["-o " dest " " dest %.reds ] print [ "Destination file:" dest ] call/wait/show/console dest halt ;}] This way pressing the shortcut I can run REBOL that compiles the program I am writing and than starts the program. Any suggestion is welcomed! | |
Arnold: 29-Apr-2013 | There is as I read this a different issue. Dock want Red to be as complete as posible, Kaj wants it to officially useable. Kaj really needs UTF-8 (and or Latin-1) character support, for getting this, I guess this has to do with the Syllable operating system amongst others. I would like Red to support time and random functions as natives and (Gregg is one of your mezz funcs REJOIN ? I want that too) be able to connect to a MySQL database so I can dump PHP for some webdevelopment. Besdies that we all love to see a VID (like) solution for display and creating apps. We have to be patient agreed 100% amongst everybody? Where the roadmap mentions all things to progress Red, above things are not on that list. I want Red to have enough to make it useable in production and after that expand, imho that is the way to really attrackt more funding/enthousiast programmers and make sure current support does not fade/ loose interest. | |
Gregg: 29-Apr-2013 | I think, and hope, the conflict over this will fade soon, and everyone will be happy again. We're just all so anxious for the things we each need, and Doc has made such great progress that it seems like Red should be almost ready to use. I was going to post that REJOIN wasn't stable yet, but decided to test it on my latest console build and it seems to work great. | |
Gregg: 29-Apr-2013 | rejoin: func [ "Returns a new string (or same series type as block/1) made from reduced values." block [block!] /local op ][ either empty? block: reduce block [block] [ op: either series? first block [:copy] [:form] append op first block next block ] ] | |
Pekr: 27-Jun-2013 | In order to be able to generate x86 target, do the following: - copy %build.r into %build-x86.r - change make-dir/deep bin-dir/lib/armeabi => make-dir/deep bin-dir/lib/x86 - change "-t Android" => "-t Android-x86" - change "rejoin [%../red/bridges/android/ bin-dir/lib/armeabi" => "rejoin [%../red/bridges/android/ bin-dir/lib/x86" - run %build-x86.r - generates an apk and if you ran arm version previously, will pack both versions into one .apk | |
Group: Announce ... Announcements only - use Ann-reply to chat [web-public] | ||
MaxV: 25-Oct-2012 | Rebol [Purpose: {make wikibook entry} Author: "Max Vessi" version: 1.0.0 ] my?: func [ "Prints information about words and values." 'word [any-type!] /local value args item type-name refmode types attrs rtype temp ][ temp: copy "" if all [word? :word not value? :word] [word: mold :word] if any [string? :word all [word? :word datatype? get :word]] [ types: dump-obj/match system/words :word sort types if not empty? types [ print ["Found these words:" newline types] exit ] print ["No information on" word "(word has no value)"] exit ] type-name: func [value] [ value: mold type? :value clear back tail value join either find "aeiou" first value ["an "] ["a "] value ] if not any [word? :word path? :word] [ append temp reduce [mold :word "is" type-name :word] exit ] value: either path? :word [first reduce reduce [word]] [get :word] if not any-function? :value [ append temp reduce [uppercase mold word "is" type-name :value "of value: "] append temp either object? value [ reduce ["^/" dump-obj value] ] [mold :value] exit ] args: third :value append temp "= USAGE: = ^/ " if not op? :value [append temp reduce [ uppercase mold word " "] ] while [not tail? args] [ item: first args if :item = /local [break] if any [all [any-word? :item not set-word? :item] refinement? :item] [ append temp reduce [append mold :item " "] if op? :value [append temp reduce [append uppercase mold word " "] value: none] ] args: next args ] append temp "^/" args: head args value: get word append temp "^/= DESCRIPTION: = ^/" either string? pick args 1 [ append temp reduce [first args] args: next args ] [ append temp "^/''(undocumented)''^/" ] append temp reduce [ "^/^/"uppercase mold word " is " type-name :value " value."] if block? pick args 1 [ attrs: first args args: next args ] if tail? args [exit] while [not tail? args] [ item: first args args: next args if :item = /local [break] either not refinement? :item [ all [set-word? :item :item = to-set-word 'return block? first args rtype: first args] if none? refmode [ append temp "^/= ARGUMENTS: =^/" refmode: 'args ] ] [ if refmode <> 'refs [ append temp "^/= REFINEMENTS: =^/" refmode: 'refs ] ] either refinement? :item [ append temp reduce ["*'''" mold item "'''"] if string? pick args 1 [append temp reduce [" -- " first args] args: next args] append temp "^/" ] [ if all [any-word? :item not set-word? :item] [ if refmode = 'refs [append temp "*"] append temp reduce ["*'''" :item "''' -- "] types: if block? pick args 1 [args: next args first back args] if string? pick args 1 [append temp reduce [first args ""] args: next args] if not types [types: 'any] append temp rejoin [" (Type: " types ")"] append temp "^/" ] ] ] if rtype [append temp reduce ["^/RETURNS:^/^-" rtype]] if attrs [ append temp "^/= (SPECIAL ATTRIBUTES) =^/" while [not tail? attrs] [ value: first attrs attrs: next attrs if any-word? value [ append temp reduce ["*'''" value "'''"] if string? pick attrs 1 [ append temp reduce [" -- " first attrs] attrs: next attrs ] append temp "^/" ] ] ] editor temp exit ] | |
Group: Ann-Reply ... Reply to Announce group [web-public] | ||
MaxV: 25-Oct-2012 | Rebol [Purpose: {make wikibook entry} Author: "Max Vessi" version: 2.0.0 ] my?: func [ "Prints information about words and values." 'word [any-type!] /local value args item type-name refmode types attrs rtype temp ][ temp: copy "" if all [word? :word not value? :word] [word: mold :word] if any [string? :word all [word? :word datatype? get :word]] [ types: dump-obj/match system/words :word sort types if not empty? types [ print ["Found these words:" newline types] exit ] print ["No information on" word "(word has no value)"] exit ] type-name: func [value] [ value: mold type? :value clear back tail value join either find "aeiou" first value ["an "] ["a "] value ] if not any [word? :word path? :word] [ append temp reduce [mold :word "is" type-name :word] exit ] value: either path? :word [first reduce reduce [word]] [get :word] if not any-function? :value [ append temp reduce [uppercase mold word "is" type-name :value "of value: "] append temp either object? value [ reduce ["^/" dump-obj value] ] [mold :value] exit ] args: third :value append temp "= USAGE: = ^/ " if not op? :value [append temp reduce [ uppercase mold word " "] ] while [not tail? args] [ item: first args if :item = /local [break] if any [all [any-word? :item not set-word? :item] refinement? :item] [ append temp reduce [append mold :item " "] if op? :value [append temp reduce [append uppercase mold word " "] value: none] ] args: next args ] append temp "^/" args: head args value: get word append temp "^/= DESCRIPTION: = ^/" either string? pick args 1 [ append temp reduce [first args] args: next args ] [ append temp "^/''(undocumented)''^/" ] append temp reduce [ "^/^/"uppercase mold word " is " type-name :value " value."] if block? pick args 1 [ attrs: first args args: next args ] if tail? args [exit] while [not tail? args] [ item: first args args: next args if :item = /local [break] either not refinement? :item [ all [set-word? :item :item = to-set-word 'return block? first args rtype: first args] if none? refmode [ append temp "^/= ARGUMENTS: =^/" refmode: 'args ] ] [ if refmode <> 'refs [ append temp "^/= REFINEMENTS: =^/" refmode: 'refs ] ] either refinement? :item [ append temp reduce ["*'''" mold item "'''"] if string? pick args 1 [append temp reduce [" -- " first args] args: next args] append temp "^/" ] [ if all [any-word? :item not set-word? :item] [ if refmode = 'refs [append temp "*"] append temp reduce ["*'''" :item "''' -- "] types: if block? pick args 1 [args: next args first back args] if string? pick args 1 [append temp reduce [first args ""] args: next args] if not types [types: 'any] append temp rejoin [" (Type: " types ")"] append temp "^/" ] ] ] if rtype [append temp reduce ["^/RETURNS:^/^-" rtype]] if attrs [ append temp "^/= (SPECIAL ATTRIBUTES) =^/" while [not tail? attrs] [ value: first attrs attrs: next attrs if any-word? value [ append temp reduce ["*'''" value "'''"] if string? pick attrs 1 [ append temp reduce [" -- " first attrs] attrs: next attrs ] append temp "^/" ] ] ] append temp "^/= Source code =^/" append temp reduce ["<pre>" join word ": "] if not value? word [print "''undefined''" exit] either any [native? get word op? get word action? get word] [ append temp reduce ["native" mold third get word] ] [append temp reduce [ mold get word "</pre>"] ] editor temp ;write clipboard:// temp exit ] | |
Group: Rebol School ... REBOL School [web-public] | ||
Gregg: 24-Apr-2012 | set 'format-phone-number func [ num [string! object!] "String or object with /text value" /def-area-code area-code [string! integer!] /local left right mid obj res ] [ left: func [s len][copy/part s len] right: func [s len] [copy skip tail s negate len] mid: func [s start len][copy/part at s start len] if object? num [obj: num num: obj/text] res: either data: parse-phone-num num [ ; discard leader if it's there. if all [11 = length? data/num data/num/1 = #"1"] [ data/num: right data/num 10 ] rejoin [ rejoin switch/default length? data/num [ 7 [ compose [ (either area-code [rejoin ["(" area-code ") "]][]) left data/num 3 "-" right data/num 4 ]] 10 [[ "(" left data/num 3 ") " mid data/num 4 3 "-" right data/num 4 ]] ][[data/num]] reduce either data/ext [[" ext" trim data/ext]] [""] reduce either data/pin [[" pin" trim data/pin]] [""] ] ][num] if obj [ obj/text: res attempt [if 'face = obj/type [show obj]] ] res ] | |
GrahamC: 14-May-2012 | You need to seed the random generator first eg. with the datestamp or something, and then generate your random number. But a better way is to create a UUID if you want something guaranteed to be unique. The library has code for windows http://www.rebol.org/view-script.r?script=guid.r Just using random, something like this should work random/seed form now/precise send [person-:-example-:-com] rejoin [ "Thank you. Your number is " random/secure 1000000 "." ] | |
JohnM: 15-May-2012 | Thank you all for addressing my concerns and for your answers about my first coding question. Ahh.. rejoin. Reading up on it makes me better understand how some things are to be done in Rebol. Continuing to the final goal... I have to extract an email address from a GET transfer. The methoed of sending the info to me is completely out of my control. An email address will be entered into a form on a website not controled by me. GET methoed will send the data to my script. The people who created the form on the external site advised that they label the email address as "trnEmailAddress". So now I want to see if I am correct in thinking how to extract and use the email address. Will using the decode a cgi form command (I know they are not commands in the tradiational sense) work. How does it work, does it create variables out of the GET (or Post when using Post, but I am forced to recieve the info via GET) stream? The GET stream in my case will include "&trnEmailAddress=person%40example%2Ecom. So can I do this? decode-cgi system/options/cgi/query-string send trnEmailAddress "Thank you. Rest of message." Thanks for your help. | |
JohnM: 16-May-2012 | Sunanda: Thanks again for issuing the World invitation. Everyone thanks for the continuing help. I have read the cited document, but it just leaves me with more questions. Is the following literal? cgi-string: read-cgi cgi-block: decode-cgi cgi-string cgi-obj: make object! cgi-block That is to say should I type exactly that? Or is cgi-string for example a theoretical variable assignment that I could call anything? Are they all proper commands, or is any part of that just for example purposes? I am thinking I should copy and paste it verbatium. I am also thinking I mispelt verbatum. I am stuck with GET. Does this mean I can leave out some code that makes up for not knowing if the original data is POST vs GET? These are hypothetical questions for better long term learning. I for now will go with the idea that everything is as straight fowarrd as it seems. I know that my GET stream will have "trnEmailAddress" in it which is a field that will contains an email address. So will the following generate a random number, extract the address and email the same random number to that email address? token: random/seed now/percise cgi-string: read-cgi cgi-block: decode-cgi cgi-string cgi-obj: make object! cgi-block send trnEmailAddress rejoin [ "Thank you. Your number is" token "." ] Graham: Thank you for the extra info on GUID, but Windows is not involved here. I realize that random number generating really isn't unless you have a monkey throwing darts at a numbered board. Regardless extra effort to make a number unique is useful and your advice appreciated. I do not think the corner cases will come up and the people who control the original form assured me that web page issues warnings if the form is not filled out correct which should help. I do realize that people are idiots, systems are not fool proof, etc. What I am saying is my basic needs are basic and I should be OK so I am not fretting over those examples. It is great though to know the solutions are out there when I need them. Tahnks. | |
Sunanda: 16-May-2012 | Yes, the names of the words are arbitrary. -- you can chose your own names. Whether the data came in via GET or POST makes no difference if you issue the READ-CGI just once. If the CGI string was yadda.com?email=[me-:-test-:-com]&token=0 then the cgi-obj will look like this: make object! [ email: "[me-:-test-:-com]" token: "0" ] Note the values are strings, so you need to convert the email value to an email! datatype: send to-email cgi-obj/email rejoin [ "Thank you. Your number is" cgi-obj/token "." ] | |
Arnold: 19-May-2012 | Found the answer to my first task: Had to read the documentation a little further and needed a function localize-file: func [file] [ rejoin [{"} to-local-file clean-path file {"}] ] Now call reform [player localize-file to-file thissong] does play the song! | |
Arnold: 23-Jun-2012 | I have a problem renaming files. rename does not change the filename on MacOSx. In the terminal it is no problem but in my script the filenames are not changed. fileo: to-file rejoin [what-dir add-suffix naam-oud-z-ext extensie] filen: to-file add-suffix naam-oud-z-ext extensie rename fileo filen I have tested with probe that the types are ok and with the resulting values for fileo and filen the rename command worked like a charm. Any more ideas what is happening and how to debug this further? Thanks. | |
Arnold: 29-Jun-2012 | Found the way to use labels that are indexed: I already had them in a panel like this panel-1: panel [across space 0x0 label "_" label "_" label "_" label "_" ; just use an underscore to see it on screen label "_" label "_" label "_" label "_" ] in a function change them like this f: func [] [ for n 1 8 1 [ waarde: to-string pick randwaarden n ; randwaarden is a block of values do rejoin ["panel-1/pane/" n "/text: " waarde]]] ; I always use rejoin in these situations. | |
Arnold: 30-Jun-2012 | When I name the labels lr1 thru lr8 and use the trick I found on www.pat665.free.fr/gtk/rebol-view.html which is w: to-word rejoin ["lr" n] (for n is 1, 2, 3 or 8 you get the picture.) and f: get :w f/font/color: white and directly show the label: show f I can set them seperately. But it is a bit ugly to do it like this if I may say so. | |
Maxim: 18-Sep-2012 | does this help? -------------------------- a: {123 abcd bla blca bla 534 hged bla blca bla 947 ahg psogie rpgioseg seo[rgieh rpgiu} digits: charset "0123456789" letters: charset [#"A" - #"Z" #"a" - #"z"] space: charset " " data: complement charset "^/" ctx: copy [ ] parse/all a [ some [ copy id some digits space copy var 3 4 letters space copy line-data some data ; we have a match for all data, add it in our container ( append ctx copy reduce [ to-set-word rejoin [var "-" id] line-data] ) "^/" ] ] ctx: context ctx probe ctx | |
Sujoy: 10-Oct-2012 | the module: install-module [ name: 'my-module on-task-received: func[data][ response: rejoin["got" data] ] ] | |
Kaj: 10-Oct-2012 | #! /usr/bin/env r2 REBOL [] here: what-dir program: dirize clean-path here/../../../cms/files/program/PowerMezz do program/mezz/module.r load-module/from program module [ imports: [ %mezz/trees.r %mezz/load-html.r %mezz/html-to-text.r ] ][ ; print mold-tree load-html read http://osslo.nl/leveranciers make-dir %data for id 1 169 1 [ print id page: load-html read join http://osslo.nl/leveranciers?mod=organization&id= id content: get-node page/childs/html/childs/body/childs/div/childs/3/childs/2 body: get-node content/childs/table/childs/tbody ; print form-html/with body [pretty?: yes] ; print mold-tree body ; item: get-node body/childs/10/childs/2 ; print form-html/with item [pretty?: yes] ; print mold-tree item ; print mold item record: copy "" short-name: name: none unless get-node body/childs/tr/childs/th [ ; Missing record foreach item get-node body/childs [ switch/default type: trim get-node item/childs/td/childs/text/prop/value [ "Logo:" [ ; if all [get-node item/childs/2/childs/1 get-node item/childs/2/childs/1/childs/1] [ ; repend record ; ['icon tab tab tab tab get-node item/childs/2/childs/a/childs/img/prop/src newline] ; ] ] "Naam:" [ if get-node item/childs/2/childs/1 [ repend record ['name tab tab tab tab name: trim/lines html-to-text get-node item/childs/2/childs/text/prop/value newline] ] ] ... "Adres:" [ unless empty? trim/lines html-to-text form-html/with get-node item/childs/2 [pretty?: yes] [ street: get-node item/childs/2/childs/1/prop/value place: get-node item/childs/2/childs/3/prop/value number: next find/last street #" " street: trim/lines html-to-text copy/part street number unless empty? street [ repend record ['street tab tab tab tab street newline] ] unless empty? number [ repend record ['number tab tab tab tab number newline] ] unless place/1 = #" " [ where: find skip place 5 #" " repend record ['postal-code tab tab tab copy/part place where newline] place: where ] unless empty? place: trim/lines html-to-text place [ repend record ['place tab tab tab tab place newline] ] ] ] "Telefoon:" [ unless #{C2} = to-binary trim/lines html-to-text form-html/with get-node item/childs/2 [pretty?: yes] [ repend record ['phones tab tab tab tab trim get-node item/childs/2/childs/text/prop/value newline] ] ] "Website:" [ if all [get-node item/childs/2/childs/1 get-node item/childs/2/childs/1/childs/1] [ repend record ['websites tab tab tab trim get-node item/childs/2/childs/a/childs/text/prop/value newline] ] ] "E-mail:" [ if all [get-node item/childs/2/childs/1 get-node item/childs/2/childs/1/childs/1] [ repend record ['mail-addresses tab tab trim/all get-node item/childs/2/childs/a/childs/text/prop/value newline] ] ] "Profiel:" [ unless #{C2} = to-binary trim/lines html-to-text form-html/with get-node item/childs/2 [pretty?: yes] [ repend record [ 'description newline tab replace/all trim html-to-text form-html/with get-node item/childs/2 [pretty?: yes] "^/" "^/^-" newline ] ] ] ][ print ["Onbekend veld: " type] ] ] write rejoin [%data/ replace/all replace/all replace/all any [short-name name] #" " #"-" #"/" #"-" #"." "" %.txt ] record ] ] ] | |
Andreas: 16-Nov-2012 | Basically, you create an HTML file and put it on your webserver. Let's call it "form.html": <form action="form.cgi"><input type="text" name="word"><input type="submit"></form> Then you create a REBOL CGI matching the "action" used above, so "form.cgi", and also put it on your webserver: #!/usr/local/bin/rebol278 -cs REBOL [] cgi-values: construct decode-cgi system/options/cgi/query-string ;; Now you can access the "word" value submitted via the HTML form ;; as cgi-values/word. ;; Let's echo the value back to the user, as an example: print rejoin [ "Content-type: text/html" crlf crlf cgi-values/word ] | |
NickA: 10-Mar-2013 | What's the proper (fast) way to do this? REBOL [title: "Anagram List"] a: copy [] mix: func [str prev] [ repeat i length? str [ picked: pick str i rest: head remove at copy str i append a rejoin [prev picked rest] mix rest join prev picked ] ] mix input: ask "Text: " "" editor unique a | |
NickA: 11-Mar-2013 | REBOL [title: "Anagram List"] a:[]m: func[s p][repeat i length? s[append a rejoin[p k: s/:i r: head remove at copy s i]m r join p k]]m ask""""editor unique a probe length? a a:[]m: func[s /local i][if 1 = i: length? s[append a copy head s exit]loop i[append s s/1 m next remove s]]m ask""editor a probe length? a halt | |
Bo: 8-May-2013 | Actually, the first method I posted above is easier to understand for a lot of nested statements. Compare this real line of script from one of my programs. The way I normally write it: browse probe rejoin copy [http://www.respectech.com/log/show-invoice.cgi?user= username "&pass=" password "&submit=" replace/all client "&" "%26" "&invno=" invnum either amtdue [rejoin ["¬ice=1&amtdue=" to-decimal amtdue "&daysdue=" daysdue]][copy ""]] Lisp-y: browse (probe (rejoin (copy [http://www.respectech.com/log/show-invoice.cgi?user= username "&pass=" password "&submit=" (replace/all (client) ("&") ("%26")) "&invno=" invnum (either amtdue [rejoin ["¬ice=1&amtdue=" (to-decimal amtdue) "&daysdue=" daysdue]][copy ""])]))) Heirarchical (takes a lot more space, but is easier to follow -- however, doesn't have the parameter enforcement of parens): browse probe rejoin copy [ http://www.respectech.com/log/show-invoice.cgi?user= username "&pass=" password "&submit=" replace/all client "&" "%26" "&invno=" invnum either amtdue [ rejoin [ "¬ice=1&amtdue=" to-decimal amtdue "&daysdue=" daysdue ] ] [ copy "" ] ] | |
Group: Databases ... group to discuss various database issues and drivers [web-public] | ||
Arnold: 11-Nov-2012 | You first check that the value is acceptable for what can be expected. This is to prevent SQL injections and other malicious input from hackers/innocent users and monkeys using your application. Than you insert a SQL command to insert or update the mysql database just like you did when you did with your select statement before. mijnquery: "INSERT INTO cms_artikel (titel, tagregel, sectie, toegevoegd, artikel_tekst) VALUES ('" mijnquery: append mijnquery rejoin [titel "', '" tagregel "', '" desectie "', '" toegevoegd "', '" artikel-tekst "')"] insert db mijnquery The names after INTO are the fieldnames of the table cms_artikel the ones after VALUES are the REBOL variables that get replaced by their values | |
afsanehsamim: 11-Nov-2012 | it means i should write like: query: "INSERT INTO data1 (oneone,onetwo,onethree) VALUES ('" query: append insert db rejoin [oneone "', '" onetwo "', '" onethree )"] insert db query | |
TomBon: 16-Nov-2012 | yes, I see. parameterized inserts are ok but perhaps better make a rejoin. | |
BrianH: 16-Nov-2012 | TomBon, don't encourage people to use rejoin for SQL queries. Definitely use parameterized queries. Building your own queries with rejoin is a sure recipe for SQL injection. | |
BrianH: 16-Nov-2012 | If you build a query dynamically with rejoin or something, the query is put together client side and then the server has to generate a new query plan for each distinct set of parameter values. This takes time and blows the query plan cache, which slows down the whole query process. | |
Group: !REBOL3 ... General discussion about REBOL 3 [web-public] | ||
GrahamC: 9-Jan-2013 | digit: charset [ #"0" - #"9" ] alpha: charset [ #"a" - #"z" #"A" - #"Z" ] idate-to-date: func [ date [string!] /local day month year zone] [ either parse date [ 5 skip copy day 2 digit space copy month 3 alpha space copy year 4 digit space copy time to space space copy zone to end ][ if zone = "GMT" [ zone: copy "+0" ] to date! rejoin [ day "-" month "-" year "/" time zone ] ][ none ] ] if headers/last-modified [info/date: attempt [ idate-to-date headers/last-modified] ] seems to work | |
GrahamC: 16-Jan-2013 | When did this behaviour of rejoin change? >> type? rejoin [ http:// "www.rebol.com" ] == url! >> rejoin [ now/date ] == "17-Jan-2013" | |
Gregg: 31-Mar-2013 | I have an updated SPLIT-PATH, modeled on Ladislav's implementation where it holds that file = rejoin split-path file This does not match current REBOL behavior. His version arguably makes more sense, but will break code in cases like this: %/c/test/test2/ REBOL == [%/c/test/ %test2/] Ladislav's == [%/c/test/test2/ %""] Ladislav's func only seems to go really wrong in the case of ending with a slash an that's the only slash in the value which return an empty path and entire filespec as the target. Schemes (http://) don't work well either. REBOL also dirizes the file path if it's %. or %.., which Ladislav's does not. e.g. [%foo/ %../] == split-path %foo/.. | |
Gregg: 31-Mar-2013 | The above matches Ladislav's REJOIN requirement, and handles a couple edge cases better. I have about 35 tests here, if people want to see them for discussion. | |
Andreas: 1-Apr-2013 | I'd also prefer a stronger invariant, as REJOIN is relatively weak for joining path components. | |
Andreas: 1-Apr-2013 | But with a "path component"-based invariant, the %. %.. and %/ cases will require more work to reconcile. With a "string"-based invariant (rejoin), those cases could more easily be described with the neutral %"" element: | |
Ladislav: 2-Apr-2013 | As said, I prefer [%"" %foo] to have the invariant that file = rejoin split-path file | |
Gregg: 2-Apr-2013 | Do our preferences come from the basic difference of whether we want SPLIT-PATH to be "smart" about file specs, or whether it should assume nothing (the REJOIN invariant case)? For example, Andreas's path invariant (p/:t) makes a lot of sense, but some of his examples' results look wrong when just viewed as results. e.g.: ; %/ [%/ %/] ; %// [%/ %/] ; %./ [%./ %./] | |
Gregg: 2-Apr-2013 | And it doesn't satisfy either the string (REJOIN) or path invariant. If we care about either of those, it's a problem. | |
Maxim: 2-Apr-2013 | but what is usefull in the rejoin invariant? we know the path before the split... | |
Andreas: 2-Apr-2013 | I'm fine with a purely REJOIN-based invariant as well. (Even though I personally find a path-based invariant more useful.) | |
Gregg: 2-Apr-2013 | Max said: "split-path shoudn't invent information which isn't given to it" I agree, if we consider split-path to be operating in string mode (the rejoin invariant). If we want to have a file-system aware option, what would we call the refinement? Or should it be a separate function? As far as returning none for either part, it strikes me as inconsistent (if convenient, which it may be). That is, if you split a series into two parts, splitting at the head or tail should just give you an empty series for that part, shouldn't it? This comes back to my SPLIT-AT question. | |
Ladislav: 13-Apr-2013 | How do you like this "Implementation artefact": f: make function! reduce [[x /local x-v y-v] body: [ x-v: either error? try [get/any 'x] [ "x does not have a value!" ] [ rejoin ["x: " mold/all :x] ] y-v: either error? try [get/any 'y] [ "y does not have a value" ] [ rejoin ["y: " mold/all :y] ] print [x-v y-v] ]] g: make function! reduce [[y /local x-v y-v] body] >> f 1 x: 1 y: 1 | |
Ladislav: 13-Apr-2013 | Just for comparison, these results are from R2: f: make function! [x /local x-v y-v] body: [ x-v: either error? try [get 'x] [ "x does not have a value" ] [ rejoin ["x: " mold/all :x] ] y-v: either error? try [get 'y] [ "y does not have a value" ] [ rejoin ["y: " mold/all :y] ] print [x-v y-v] unless value? 'y [g 2] ] g: make function! [y /local x-v y-v] body >> f 1 x: 1 y does not have a value x does not have a value y: 2 |
world-name: r3wp
Group: !AltME ... Discussion about AltME [web-public] | ||
Henrik: 14-Oct-2006 | >> t/text: rejoin ["this is" newline "a" newline "test"] == "this is^/a^/test" >> show t That works | |
Group: RAMBO ... The REBOL bug and enhancement database [web-public] | ||
Izkata: 18-Mar-2005 | print rejoin [" " "whatever" " "] ; ;) | |
Group: Core ... Discuss core issues [web-public] | ||
sqlab: 24-Jan-2005 | load mold works too >> t: rejoin [ [] to-word "[" to-word "]"] == [[ ]] >> load mold t == [[]] >> type? first load mold t == block! >> | |
JaimeVargas: 8-Mar-2005 | >> cidr-as-mask: func[prefix /local mask][ [ mask: make string! 34 [ repeat i 32 [insert tail mask either prefix >= i [1][0]] [ to-tuple load rejoin ["2#{" mask "}"] [ ] >> >> same-subnet?: func [src dst mask [tuple! integer!]][ [ if integer! = type? mask [mask: cidr-as-mask mask] [ (src and mask) = (dst and mask) [ ] >> same-subnet? 10.10.10.0 10.10.10.5 255.255.255.0 == true >> same-subnet? 10.10.10.0 10.10.10.5 24 == true >> same-subnet? 10.10.10.0 10.10.9.5 255.255.255.0 == false >> same-subnet? 10.10.10.0 10.10.9.5 24 == false | |
Graham: 12-Mar-2005 | I used 1'000'000 here .. don't know if it's enough generate-messageid: does [ rejoin [ "<" enbase form now/time/precise "." enbase form random 1000000 "@" server-name ">"] ] | |
Gabriele: 12-Mar-2005 | generate-messageid: does [ rejoin ["<" enbase checksum/secure random/secure mold system/error "@" server-name ">"] ] | |
Graham: 12-Mar-2005 | generate-messageid: func [eml [string!] [ rejoin ["<" enbase checksum/secure random/secure eml "@" server-name ">"] ] | |
Micha: 16-Mar-2005 | ;serwer proxy p: make port! tcp://:80 p/awake: func [ port /local data conn targed cmd partner url ] [ conn: first port wait conn data: to-string copy conn replace/all data "^M" "" source data targed: copy/part data find data "HTTP/1.1" data: find/tail data "^/" print targed cmd: parse targed none url: decode-url cmd/2 if not url/path [url/path: "" ] if not url/target [url/target: ""] partner: open/no-wait to-url rejoin [ "tcp://" url/host ":80" ] insert partner rejoin [ cmd/1" /" url/path url/target " HTTP/1.1^/" data] wait partner tmp: copy partner close partner insert conn tmp close conn ] append system/ports/wait-list p open/binary/no-wait p wait [] halt | |
Anton: 16-Mar-2005 | insert partner rejoin [ cmd/1" /" url/path url/target " HTTP/1.1^/" data] ?? data wait partner | |
Chris: 30-Mar-2005 | >> foo: [a [does this]] == [a [does this]] >> bar: [b [does that]] == [b [does that]] >> rejoin [foo bar] == [a [does this] [b [does that]]] Is there an equivelant function that would give me: == [a [does this] b [does that]] | |
Chris: 30-Mar-2005 | Yep, I can fudge it that way, but I was looking for a single function, like 'rejoin or 'reduce | |
Group: Script Library ... REBOL.org: Script library and Mailing list archive [web-public] | ||
Andreas: 20-Oct-2010 | Or, depending on where the SCRIPT-SOURCE in the above comes from, you do one unchecked reform/rejoin somewhere. | |
Andreas: 20-Oct-2010 | HTTP requires CRLF termination anyway, so what I usually do is sthg like: prin rejoin [ "Some-Header:" some-value crlf "Another-Header:" another-value crlf crlf ] | |
Group: Parse ... Discussion of PARSE dialect [web-public] | ||
BrianH: 22-Aug-2005 | parse/all data [any [to "*" a: skip b: to "*" c: skip d: :a (change/part a rejoin ["<strong>" copy/part b c "</strong>"] d)] to end] | |
BrianH: 22-Aug-2005 | markup-chars: charset "*~" non-markup: complement markup-chars tag1: ["*" "<strong>" "~" "<i>"] tag2: ["*" "</strong>" "~" "</i>"] parse/all data [ any non-markup any [ ["*" a: skip b: to "*" c: skip d: | "~" a: skip b: to "~" c: skip d: ] :a ( change/part a rejoin [ select tag1 copy/part a b copy/part b c select tag2 copy/part c d ] d ) any non-markup ] to end ] | |
BrianH: 22-Aug-2005 | Here's a simplified version of my example that can handle multiple instances of multiple markup types and be adapted to different end tags (thanks Tomc for the idea!): markup-chars: charset "*~" non-markup: complement markup-chars tag1: ["*" "<strong>" "~" "<i>"] tag2: ["*" "</strong>" "~" "</i>"] parse/all data [ any non-markup any [ ; This next block can be generated if you have many markup types... [a: copy b "*" copy c to "*" copy d "*" e: | a: copy b "~" copy c to "~" copy d "~" e: ] :a (change/part a rejoin [tag1/:b c tag2/:d] e) any non-markup ] to end ] | |
Group: MySQL ... [web-public] | ||
MikeL: 23-Aug-2005 | Hi Petr, Not sure if this is what you are asking about mySQL "Can I update particular fields (columns) in table?" but if you want to change a value you use SET. e.g. in mySQL protocol format query: rejoin[{update logons set rs='}keyOrder{' where userName = '}cgi/userName{'}] insert db reduce query | |
Pekr: 6-Feb-2006 | Doc, one forgotten probe probably ... go look into do-handshake function and the part where you send-packet port probe rejoin [] ... the probe should not be there probably ... | |
Group: Linux ... [web-public] group for linux REBOL users | ||
Graham: 27-Jan-2006 | Volker is suggesting this: escape-metachars: func["escape metachars" s][ replace/all s "'" "''" rejoin ["'" s "'"] ] browse: func[url]compose/deep[ call rejoin ["screen -X screen -- " (view-root/bin/browser.sh) " " escape-metachars url] ] | |
[unknown: 10]: 3-Mar-2006 | rejoin | |
Frank: 15-Dec-2006 | For the browser i use this in my user.r browse*: :browse browse: func [ value [any-string!] /only ] [ call rejoin[{/usr/local/firefox/firefox "} to-url (value) {"}] ] | |
Graham: 5-Apr-2007 | forever [ if error? set/any 'err try [ d: read daytime://192.168.220.2 d: load d call rejoin [ "date -s " {"} d/month "/" d/day "/" d/year " " d/time {"} ] ][ print mold disarm err ] wait 0:02:00 ] ] | |
btiffin: 9-Apr-2007 | Alan; the sensible-browser seems to be a Debain branch feature. It's GPL so we can work that out. The hint I left for the RAMBO folk is to internally call sensible-browser. This won't work for us until RT does a build. Once/if that is done, we can talk/plan more, about documenting getting browse native functioning. In the meantime, try the browse: [url /only] call reform ["path to browser command" rejoin [{"} url {"}]] redef. If you know the switches for your browser, you can even code this to support /only. | |
Kaj: 19-Feb-2008 | form-money: func [ m /local r ][ if money? m [m: m/2] r: (to-integer (absolute m) * 100 + 0.5) // 100 rejoin [ either negative? m ["-"] [""] absolute to-integer m "," either r < 10 ["0"] [""] r ] ] | |
Group: !Readmail ... a Rebol mail client [web-public] | ||
Graham: 17-May-2005 | From Didier ; decode ISO-8859-1 / ASCII-US encoded text decode-iso8859: func [str /local ascii non-ascii char text emit quoted-printable encoded-word res b e] [ emit: func [v][append res v] ascii: charset [#" " - #"^(7f)"] non-ascii: complement ascii text: exclude union ascii non-ascii charset ["="] char: exclude ascii charset ["?_=^-"] encoded-word: [ "=?" ["ISO-8859-1" | "us-ascii"] [ "?q?" some quoted-printable | "?b?" b: to "?" e: (emit to-string debase copy/part b e) ] "?=" ] quoted-printable: [ "_" (emit #" ") | b: some char e: (emit copy/part b e) | b: "=" (emit do rejoin [ {#"^^(} second b third b {)"} ]) 2 skip ] res: make string! length? str parse/all str [any [encoded-word | "=" (emit #"=") | "^/ " | b: some text e: (emit copy/part b e)] to end] res ] | |
Group: !Uniserve ... Creating Uniserve processes [web-public] | ||
Graham: 5-Mar-2005 | REBOL [ Title: "SMTP daemon" Author: "Graham Chiu" Version: 0.0.1 Date: 5/3/2005 ] install-service [ name: 'smtp port-id: 25 multi-line-end: rejoin [crlf #"." crlf] stop-at: crlf server: make object! [ user-data: none ] maildir: %mail/ ; store mail here save-mail: func [ data /local mailbox ][ if not dir? mailbox: rejoin [ maildir server/user-data/email "/" ] [ if not exists? join maildir %misc/ [ mailbox: make-dir join maildir %misc/ ] ] if not exists? join mailbox "mail.txt" [ write join mailbox "mail.txt" "" ] write/append join mailbox "mail.txt" join crlf to-string data print dehex data ] on-new-client: has [su] [ su: server/user-data: context [ state: copy "command" email: none ] stop-at: crlf write-client join "220 mail.compkarori.co.nz SMTP" crlf ] smtp-rule: [ "HELO" thru newline ( write-client join "250 mail.compkarori.co.nz SMTP" crlf ) | "EHLO" thru newline ( write-client join "500 not implemented" crlf ) | "MAIL" thru newline ( write-client join "250 OK MAIL FROM" crlf) | "QUIT" thru newline ( write-client join "221 Good Bye" crlf close-client) | "RSET" thru newline ( write-client join "250 OK RESET" crlf server/user-data/state: copy "command" ) | "NOOP" thru newline ( write-client join "250 OK NOOP" crlf ) | "VRFY" thru newline ( write-client join "252 send some mail, i'll try my best" crlf ) | "EXPN" thru newline ( write-client join "500 not implemented" crlf ) | "RCPT" [ thru "<" | thru ": " ] copy name to "@" thru newline ( server/user-data/email: form name write-client join "250 OK RCPT TO" crlf ) | "DATA" thru newline ( stop-at: multi-line-end server/user-data/state: copy "body" ) ] on-received: func [data /local su] [ su: server/user-data print join "Data: " data switch su/state [ "command" [ if not parse data smtp-rule [ write-client join "500 command not understood" crlf ] ] "body" [ ; reject if we don't have a RCPT command first if none? su/email [ write-client join "500 no email address received" crlf stop-at: crlf su/state: copy "command" return ] ; write the body of the message somewhere save-mail rejoin [ "Received: from somewhere at " to-idate now newline dehex data newline newline ] stop-at: crlf write-client join "250 OK MAIL received" crlf su/state: "command" su/email: none ] ] ] ] | |
Graham: 5-Mar-2005 | REBOL [ Title: "SMTP daemon" Author: "Graham Chiu" Version: 0.0.2 Date: 5/3/2005 ] install-service [ name: 'smtp port-id: 25 multi-line-end: rejoin [crlf #"." crlf] stop-at: crlf server: make object! [ user-data: none ] clear-server: server/user-data [ state: "command" email: computer: none ] maildir: %mail/ ; store mail here domains: [ "@compkarori.co.nz" ] ; list of accepted domains save-mail: func [ data /local mailbox ][ if not dir? mailbox: rejoin [ maildir server/user-data/email "/" ] [ if not exists? mailbox: join maildir %misc/ [ mailbox: make-dir join maildir %misc/ ] ] if not exists? join mailbox "mail.txt" [ write join mailbox "mail.txt" "" ] write/append join mailbox "mail.txt" join crlf to-string data ; print dehex data ] on-new-client: has [su] [ su: server/user-data: context [ state: copy "command" email: computer: none ] stop-at: crlf write-client join "220 mail.compkarori.co.nz SMTP" crlf ] smtp-rule: [ "HELO" copy name thru newline ( write-client join "250 mail.compkarori.co.nz SMTP" crlf if not none? name [ trim/head/tail name ] server/user-data/computer: form name ) | "EHLO" thru newline ( write-client join "500 not implemented" crlf ) | "MAIL" thru newline ( write-client join "250 OK MAIL FROM" crlf) | "QUIT" thru newline ( write-client join "221 Good Bye" crlf close-client) | "RSET" thru newline ( write-client join "250 OK RESET" crlf clear-server ) | "NOOP" thru newline ( write-client join "250 OK NOOP" crlf ) | "VRFY" thru newline ( write-client join "252 send some mail, i'll try my best" crlf ) | "EXPN" thru newline ( write-client join "500 not implemented" crlf ) | "RCPT" [ thru "<" | thru ": " ] copy name to "@" copy domain to ">" thru newline ( either find domains domain [ server/user-data/email: form name write-client join "250 OK RCPT TO" crlf ][ write-client join "553 sorry, that domain is not in my list of allowed rcpthosts" crlf server/user-data/email: none ] ) | "DATA" thru newline ( stop-at: multi-line-end server/user-data/state: copy "body" write-client join "354 start mail input" crlf ) ] on-received: func [data /local su] [ su: server/user-data ; print join "Data: " data switch su/state [ "command" [ if not parse data smtp-rule [ write-client join "500 command not understood" crlf ] ] "body" [ ; reject if we don't have a RCPT command first if none? su/email [ write-client join "500 no email address received" crlf stop-at: crlf su/state: copy "command" return ] ; write the body of the message somewhere save-mail rejoin [ "Received: from " su/computer " ( " su/computer " [ " client/remote-ip " ]) " to-idate now newline dehex data newline newline ] stop-at: crlf write-client join "250 OK MAIL received" crlf su/state: "command" su/email: none ] ] ] ] | |
Group: XML ... xml related conversations [web-public] | ||
Graham: 22-Jun-2009 | format-xml: func [ xml /local out space prev ][ out: copy "" spacer: copy "" prev: copy </tag> foreach tag load/markup xml [ either tag = find tag "/" [ ; we have a close tag ; reduce the spacer by a tab unless the previous was an open tag either not tag? prev [ ; not a tag remove/part spacer 4 ][ ; is a tag if prev = find prev "/" [ ; last was a closing tag remove/part spacer 4 ] ] ][ either tag? tag [ ; current is tag ; indent only if the prev is not a closing tag if not prev = find prev "/" [ insert/dup spacer " " 4 ] ][ ; is data insert/dup spacer " " 4 ] ] repend out rejoin [ spacer tag newline ] prev: copy tag ] view layout compose [ area (out) 400x400 ] ] obj2xml: func [ obj [object!] out [string!] /local o ][ foreach element next first obj [ repend out [ to-tag element ] either object? o: get in obj element [ obj2xml o out ][ repend out any [ o copy "" ] ] repend out [ to-tag join "/" element ] ] ] | |
Maxim: 24-Jun-2009 | in the later, you can add code in the addressobj which will be executed everytime you create an object using it. for example: addressobj: [ number: 666 street: "styx lane" city: "pandemonium" address: rejoin [number " " street " " city] ] | |
Oldes: 13-Oct-2010 | It depends what's your input and how should look the output, but you can use something like that: context [ xml: copy "" tabs: copy "" set 'to-xml func[node /init][ if init [ xml: copy "" tabs: copy "" ] switch/default type?/word node [ object! [ append tabs #"^-" foreach child next first node [ append xml rejoin [tabs "<" child ">^/"] to-xml node/(child) append xml rejoin [tabs "</" child ">^/"] ] remove tabs ] ][ append xml rejoin [ tabs "<" type? node ">" node "</" type? node ">^/" ] ] xml ] ] o: context [ person: context [ name: "bla" age: 1 ] ] print rejoin [ "<o>^/" to-xml o "</o>" ] | |
Group: SVG Renderer ... SVG rendering in Draw AGG [web-public] | ||
shadwolf: 23-Jun-2005 | REBOL [ Title: "SVG Demo" Owner: "Ashley G. Trüter" Version: 0.0.1 Date: 21-Jun-2005 Purpose: "Loads and displays a resizeable SVG file." History: { 0.0.1 Initial release } Notes: { Tested on very simple SVG icons Only a few basic styles / attributes / commands supported Does not handle sizes in units other than pixels (e.g. pt, in, cm, mm, etc) SVG path has an optional close command, "z" ... AGG shape equivalent auto-closes load-svg function needs to be totally refactored / optimized ... *sample only* } ] ; The following commands are available for path data: ; ; M = moveto ; L = lineto ; H = horizontal lineto ; V = vertical lineto ; C = curveto ; S = smooth curveto ; Q = quadratic Belzier curve ; T = smooth quadratic Belzier curveto ; A = elliptical Arc ; Z = closepath ;print: none ; comment out this line to enable debug messages load-svg: function [svg-file [file! string!] size [pair!]] [ id defs x y to-color to-byte draw-blk append-style svg-size scale-x scale-y ][ xml: either string? svg-file [parse-xml svg-file] [ unless %.svg = suffix? svg-file [to error! "File has an invalid suffix!"] parse-xml read svg-file ] unless xml/3/1/1 = "svg" [to error! "Could not find SVG header!"] ;unless find ["id" "xmlns"] xml/3/1/2/1 [to error! "Could not find ID header!"] ;unless xml/3/1/3/1/1 = "defs" [to error! "Could not find DEFS header!"] id: xml/3/1/2 defs: xml/3/1/3 ; ; --- Parse SVG id ; svg-size: either find ["32pt" "48pt" "72pt"] select id "width" [ switch select id "width" [ "72pt" [120x120] "48pt" [80x80] "32pt" [60x60] ] ][ as-pair to integer! any [select id "width" "100"] to integer! any [select id "height" "100"] ] x: to integer! any [select id "x" "0"] y: to integer! any [select id "y" "0"] scale-x: size/x / svg-size/x scale-y: size/y / svg-size/y ; ; --- Helper functions ; to-color: func [s [string!]] [ ; converts a string in the form "#FFFFFF" to a 4-byte tuple to tuple! load rejoin ["#{" next s "00}"] ] to-byte: func [s [string!]] [ ; converts a string with a value 0-1 to an inverted byte 255 - to integer! 255 * to decimal! s ] ; ; --- Parse SVG defs ; draw-blk: copy [] append-style: function [ command [string!] blk [block!] ][ x xy pen-color fill-color line-width mode size radius shape closed? matrix transf-command ][ xy: 0x0 size: 0x0 line-width: 1 matrice: make block! [] radius: none transf-command: none foreach [attr val] blk [ switch attr [ "transform" [print "tranform have been found" ;probe val halt val: parse val "()," transf-command: first val probe transf-command switch transf-command [ "matrix" [ foreach word val [ if not find word "matrix" [ insert tail matrice to-decimal word ] ] ] ] ] "style" [ foreach [attr val] parse val ":;" [ switch/default attr [ "font-size" [ ] "stroke" [ switch/default first val [ #"#" [pen-color: to-color val] #"n" [pen-color: none] ][ print ["Unknown stroke:" val] ] ] "stroke-width" [line-width: to decimal! val] "fill" [ fill-color: switch/default first val [ #"#" [to-color val] #"n" [none] ][ print ["Unknown fill value:" val] none ] ] "fill-rule" [ mode: switch/default val [ "evenodd" ['even-odd] ][ print ["Unknown fill-rule value:" val] none ] ] "stroke-opacity" [pen-color: any [pen-color 0.0.0.0] pen-color/4: to-byte val] "fill-opacity" [fill-color: any [fill-color 0.0.0.0] fill-color/4: to-byte val] "stroke-linejoin" [ insert tail draw-blk switch/default val [ "miter" [compose [line-join miter]] "round" [compose [line-join round]] "bevel" [compose [line-join bevel]] ][ print ["Unknown stroke-linejoin value:" val] none ] ] "stroke-linecap" [ insert tail draw-blk 'line-cap insert tail draw-blk to word! val ] ][ print ["Unknown style:" attr] ] ] ] "x" [xy/x: scale-x * val] "y" [xy/y: scale-y * val] "width" [size/x: scale-x * val] "height" [size/y: scale-y * val] "rx" [print "rx"] "ry" [radius: to decimal! val] "d" [ shape: copy [] x: none closed?: false foreach token load val [ switch/default token [ M [insert tail shape 'move] C [insert tail shape 'curve] L [insert tail shape 'line] z [closed?: true] ][ unless number? token [print ["Unknown path command:" token]] either x [insert tail shape as-pair x scale-y * token x: none] [x: scale-x * token] ] ] ] ] ] insert tail draw-blk compose [ pen (pen-color) fill-pen (fill-color) fill-rule (mode) line-width (line-width * min scale-x scale-y) ] switch command [ "rect" [ insert tail draw-blk compose [box (xy) (xy + size)] if radius [insert tail draw-blk radius] ] "path" [ unless closed? [print "Path closed"] either transf-command <> none [ switch transf-command [ "matrix" [insert tail draw-blk compose/only [ (to-word transf-command) (matrice) shape (shape) reset-matrix]] ] ][ insert tail draw-blk compose/only [shape (shape)] ] ] "g" [ print "Write here how to handle G insertion to Draw block" insert tail draw-blk probe compose/only [reset-matrix (to-word transf-command) (matrice)] ] ] ] probe defs foreach blk defs [ switch first blk [ "rect" [append-style first blk second blk] "path" [append-style first blk second blk] "g" [ print "key word" probe first blk print "matrix and style in G" probe second blk append-style first blk second blk ;print "what to draw in G" probe third blk foreach blk2 third blk [ probe blk2 switch first blk2[ "path" [append-style first blk2 second blk2] ] ] ] ] ] probe draw-blk draw-blk ] view make face [ offset: 100x100 size: 200x200 action: request-file/filter/only "*.svg" text: rejoin ["SVG Demo [" last split-path action "]"] data: read action color: white effect: compose/only [draw (load-svg data size)] edge: font: para: none feel: make feel [ detect: func [face event] [ if event/type = 'resize [ insert clear face/effect/draw load-svg face/data face/size show face ] if event/type = 'close [quit] ] ] options: [resize] ] | |
shadwolf: 23-Jun-2005 | REBOL [ Title: "SVG Demo" Owner: "Ashley G. Trüter" Version: 0.0.1 Date: 21-Jun-2005 Purpose: "Loads and displays a resizeable SVG file." History: { 0.0.1 Initial release } Notes: { Tested on very simple SVG icons Only a few basic styles / attributes / commands supported Does not handle sizes in units other than pixels (e.g. pt, in, cm, mm, etc) SVG path has an optional close command, "z" ... AGG shape equivalent auto-closes load-svg function needs to be totally refactored / optimized ... *sample only* } ] ; The following commands are available for path data: ; ; M = moveto ; L = lineto ; H = horizontal lineto ; V = vertical lineto ; C = curveto ; S = smooth curveto ; Q = quadratic Belzier curve ; T = smooth quadratic Belzier curveto ; A = elliptical Arc ; Z = closepath ;print: none ; comment out this line to enable debug messages load-svg: function [svg-file [file! string!] size [pair!]] [ id defs x y to-color to-byte draw-blk append-style svg-size scale-x scale-y ][ xml: either string? svg-file [parse-xml svg-file] [ unless %.svg = suffix? svg-file [to error! "File has an invalid suffix!"] parse-xml read svg-file ] unless xml/3/1/1 = "svg" [to error! "Could not find SVG header!"] ;unless find ["id" "xmlns"] xml/3/1/2/1 [to error! "Could not find ID header!"] ;unless xml/3/1/3/1/1 = "defs" [to error! "Could not find DEFS header!"] id: xml/3/1/2 defs: xml/3/1/3 ; ; --- Parse SVG id ; svg-size: either find ["32pt" "48pt" "72pt"] select id "width" [ switch select id "width" [ "72pt" [120x120] "48pt" [80x80] "32pt" [60x60] ] ][ as-pair to integer! any [select id "width" "100"] to integer! any [select id "height" "100"] ] x: to integer! any [select id "x" "0"] y: to integer! any [select id "y" "0"] scale-x: size/x / svg-size/x scale-y: size/y / svg-size/y ; ; --- Helper functions ; to-color: func [s [string!]] [ ; converts a string in the form "#FFFFFF" to a 4-byte tuple to tuple! load rejoin ["#{" next s "00}"] ] to-byte: func [s [string!]] [ ; converts a string with a value 0-1 to an inverted byte 255 - to integer! 255 * to decimal! s ] ; ; --- Parse SVG defs ; draw-blk: copy [] append-style: function [ command [string!] blk [block!] ][ x xy pen-color fill-color line-width mode size radius shape closed? matrix transf-command ][ xy: 0x0 size: 0x0 line-width: 1 matrice: make block! [] radius: none transf-command: none foreach [attr val] blk [ switch attr [ "transform" [print "tranform have been found" ;probe val halt val: parse val "()," transf-command: first val probe transf-command switch transf-command [ "matrix" [ foreach word val [ if not find word "matrix" [ insert tail matrice to-decimal word ] ] ] ] ] "style" [ foreach [attr val] parse val ":;" [ switch/default attr [ "font-size" [ ] "stroke" [ switch/default first val [ #"#" [pen-color: to-color val] #"n" [pen-color: none] ][ print ["Unknown stroke:" val] ] ] "stroke-width" [line-width: to decimal! val] "fill" [ fill-color: switch/default first val [ #"#" [to-color val] #"n" [none] ][ print ["Unknown fill value:" val] none ] ] "fill-rule" [ mode: switch/default val [ "evenodd" ['even-odd] ][ print ["Unknown fill-rule value:" val] none ] ] "stroke-opacity" [pen-color: any [pen-color 0.0.0.0] pen-color/4: to-byte val] "fill-opacity" [fill-color: any [fill-color 0.0.0.0] fill-color/4: to-byte val] "stroke-linejoin" [ insert tail draw-blk switch/default val [ "miter" [compose [line-join miter]] "round" [compose [line-join round]] "bevel" [compose [line-join bevel]] ][ print ["Unknown stroke-linejoin value:" val] none ] ] "stroke-linecap" [ insert tail draw-blk 'line-cap insert tail draw-blk to word! val ] ][ print ["Unknown style:" attr] ] ] ] "x" [xy/x: scale-x * val] "y" [xy/y: scale-y * val] "width" [size/x: scale-x * val] "height" [size/y: scale-y * val] "rx" [print "rx"] "ry" [radius: to decimal! val] "d" [ shape: copy [] x: none closed?: false foreach token load val [ switch/default token [ M [insert tail shape 'move] C [insert tail shape 'curve] S [insert tail shape 'curv] L [insert tail shape 'line] Q [insert tail shape 'qcurve] T [insert tail shape 'qcurv] z [closed?: true] H [insert tail shape 'hline] V [insert tail shape 'vline] A [insert tail shape 'arc] ][ unless number? token [print ["Unknown path command:" token]] either x [insert tail shape as-pair x scale-y * token x: none] [x: scale-x * token] ] ] ] ] ] insert tail draw-blk compose [ pen (pen-color) fill-pen (fill-color) fill-rule (mode) line-width (line-width * min scale-x scale-y) ] switch command [ "rect" [ insert tail draw-blk compose [box (xy) (xy + size)] if radius [insert tail draw-blk radius] ] "path" [ unless closed? [print "Path closed"] either transf-command <> none [ switch transf-command [ "matrix" [insert tail draw-blk compose/only [ (to-word transf-command) (matrice) shape (shape) reset-matrix]] ] ][ insert tail draw-blk compose/only [shape (shape)] ] ] "g" [ print "Write here how to handle G insertion to Draw block" insert tail draw-blk probe compose/only [reset-matrix (to-word transf-command) (matrice)] ] ] ] probe defs foreach blk defs [ switch first blk [ "rect" [append-style first blk second blk] "path" [append-style first blk second blk] "g" [ print "key word" probe first blk print "matrix and style in G" probe second blk append-style first blk second blk ;print "what to draw in G" probe third blk foreach blk2 third blk [ probe blk2 switch first blk2[ "path" [append-style first blk2 second blk2] ] ] ] ] ] probe draw-blk draw-blk ] view make face [ offset: 100x100 size: 200x200 action: request-file/filter/only "*.svg" text: rejoin ["SVG Demo [" last split-path action "]"] data: read action color: white effect: compose/only [draw (load-svg data size)] edge: font: para: none feel: make feel [ detect: func [face event] [ if event/type = 'resize [ insert clear face/effect/draw load-svg face/data face/size show face ] if event/type = 'close [quit] ] ] options: [resize] ] | |
shadwolf: 23-Jun-2005 | REBOL [ Title: "SVG Demo" Owner: "Ashley G. Trüter" Version: 0.0.1 Date: 21-Jun-2005 Purpose: "Loads and displays a resizeable SVG file." History: { 0.0.1 Initial release } Notes: { Tested on very simple SVG icons Only a few basic styles / attributes / commands supported Does not handle sizes in units other than pixels (e.g. pt, in, cm, mm, etc) SVG path has an optional close command, "z" ... AGG shape equivalent auto-closes load-svg function needs to be totally refactored / optimized ... *sample only* } ] ; The following commands are available for path data: ; ; M = moveto ; L = lineto ; H = horizontal lineto ; V = vertical lineto ; C = curveto ; S = smooth curveto ; Q = quadratic Belzier curve ; T = smooth quadratic Belzier curveto ; A = elliptical Arc ; Z = closepath ;print: none ; comment out this line to enable debug messages load-svg: function [svg-file [file! string!] size [pair!]] [ id defs x y to-color to-byte draw-blk append-style svg-size scale-x scale-y ][ xml: either string? svg-file [parse-xml svg-file] [ unless %.svg = suffix? svg-file [to error! "File has an invalid suffix!"] parse-xml read svg-file ] unless xml/3/1/1 = "svg" [to error! "Could not find SVG header!"] ;unless find ["id" "xmlns"] xml/3/1/2/1 [to error! "Could not find ID header!"] ;unless xml/3/1/3/1/1 = "defs" [to error! "Could not find DEFS header!"] id: xml/3/1/2 defs: xml/3/1/3 ; ; --- Parse SVG id ; svg-size: either find ["32pt" "48pt" "72pt"] select id "width" [ switch select id "width" [ "72pt" [120x120] "48pt" [80x80] "32pt" [60x60] ] ][ as-pair to integer! any [select id "width" "100"] to integer! any [select id "height" "100"] ] x: to integer! any [select id "x" "0"] y: to integer! any [select id "y" "0"] scale-x: size/x / svg-size/x scale-y: size/y / svg-size/y ; ; --- Helper functions ; to-color: func [s [string!]] [ ; converts a string in the form "#FFFFFF" to a 4-byte tuple to tuple! load rejoin ["#{" next s "00}"] ] to-byte: func [s [string!]] [ ; converts a string with a value 0-1 to an inverted byte 255 - to integer! 255 * to decimal! s ] ; ; --- Parse SVG defs ; draw-blk: copy [] append-style: function [ command [string!] blk [block!] ][ x xy pen-color fill-color line-width mode size radius shape closed? matrix transf-command ][ xy: 0x0 size: 0x0 line-width: 1 matrice: make block! [] radius: none transf-command: none foreach [attr val] blk [ switch attr [ "transform" [print "tranform have been found" ;probe val halt val: parse val "()," transf-command: first val probe transf-command switch transf-command [ "matrix" [ foreach word val [ if not find word "matrix" [ insert tail matrice to-decimal word ] ] ] ] ] "style" [ foreach [attr val] parse val ":;" [ switch/default attr [ "font-size" [ ] "stroke" [ switch/default first val [ #"#" [pen-color: to-color val] #"n" [pen-color: none] ][ print ["Unknown stroke:" val] ] ] "stroke-width" [line-width: to decimal! val] "fill" [ fill-color: switch/default first val [ #"#" [to-color val] #"n" [none] ][ print ["Unknown fill value:" val] none ] ] "fill-rule" [ mode: switch/default val [ "evenodd" ['even-odd] ][ print ["Unknown fill-rule value:" val] none ] ] "stroke-opacity" [pen-color: any [pen-color 0.0.0.0] pen-color/4: to-byte val] "fill-opacity" [fill-color: any [fill-color 0.0.0.0] fill-color/4: to-byte val] "stroke-linejoin" [ insert tail draw-blk switch/default val [ "miter" [compose [line-join miter]] "round" [compose [line-join round]] "bevel" [compose [line-join bevel]] ][ print ["Unknown stroke-linejoin value:" val] none ] ] "stroke-linecap" [ insert tail draw-blk 'line-cap insert tail draw-blk to word! val ] ][ print ["Unknown style:" attr] ] ] ] "x" [xy/x: scale-x * val] "y" [xy/y: scale-y * val] "width" [size/x: scale-x * val] "height" [size/y: scale-y * val] "rx" [print "rx"] "ry" [radius: to decimal! val] "d" [ shape: copy [] x: none closed?: false if all [x not number? token] [ insert tail shape x * either token = 'V [scale-y][scale-x] x: none ] foreach token load val [ switch/default token [ M [insert tail shape 'move] C [insert tail shape 'curve] S [insert tail shape 'curv] L [insert tail shape 'line] Q [insert tail shape 'qcurve] T [insert tail shape 'qcurv] z [closed?: true] H [insert tail shape 'hline] V [insert tail shape 'vline] A [insert tail shape 'arc] ][ unless number? token [print ["Unknown path command:" token]] either x [insert tail shape as-pair x scale-y * token x: none] [x: scale-x * token] ] ] ] ] ] insert tail draw-blk compose [ pen (pen-color) fill-pen (fill-color) fill-rule (mode) line-width (line-width * min scale-x scale-y) ] switch command [ "rect" [ insert tail draw-blk compose [box (xy) (xy + size)] if radius [insert tail draw-blk radius] ] "path" [ unless closed? [print "Path closed"] either transf-command <> none [ switch transf-command [ "matrix" [insert tail draw-blk compose/only [ (to-word transf-command) (matrice) shape (shape) reset-matrix]] ] ][ insert tail draw-blk compose/only [shape (shape)] ] ] "g" [ print "Write here how to handle G insertion to Draw block" insert tail draw-blk probe compose/only [reset-matrix (to-word transf-command) (matrice)] ] ] ] probe defs foreach blk defs [ switch first blk [ "rect" [append-style first blk second blk] "path" [append-style first blk second blk] "g" [ print "key word" probe first blk print "matrix and style in G" probe second blk append-style first blk second blk ;print "what to draw in G" probe third blk foreach blk2 third blk [ probe blk2 switch first blk2[ "path" [append-style first blk2 second blk2] ] ] ] ] ] probe draw-blk draw-blk ] view make face [ offset: 100x100 size: 200x200 action: request-file/filter/only "*.svg" text: rejoin ["SVG Demo [" last split-path action "]"] data: read action color: white effect: compose/only [draw (load-svg data size)] edge: font: para: none feel: make feel [ detect: func [face event] [ if event/type = 'resize [ insert clear face/effect/draw load-svg face/data face/size show face ] if event/type = 'close [quit] ] ] options: [resize] ] | |
Group: Sound ... discussion about sound and audio implementation in REBOL [web-public] | ||
Rebolek: 16-Aug-2005 | I'm using this code (and I really hope there's some better solution): >> insert tail sample do rejoin ["#{" skip to-hex to integer! (sample-value + 1) * 32767.5 4 "}"] | |
Group: Rebol School ... Rebol School [web-public] | ||
Gregg: 27-Jun-2007 | rejoin extract my-unicode-string 2 | |
PatrickP61: 27-Jun-2007 | Hi Gregg -- So should I do something like this: InText: rejoin extract Read InFile 2 | |
PatrickP61: 27-Jun-2007 | It works!!!! Code to convert UNICODE to InFile: %"Test In unicode.txt" InText: rejoin extract Read InFile 2 write OutFile InText | |
PatrickP61: 27-Jun-2007 | When you try to save a document under Notebook, the encoding choices are UTF-8, UNICODE, ANSI among others. UNICODE may be the same as UTF-16 because it does look like every single character is saved as two bytes. The code (rejoin extract read InFile 2) does eliminate the double characters but I noticed that the entire file is still double spaced -- as if the newline is coded twice and not removed from the rejoin. But that extra newline may be an annoyance than anything else. | |
PatrickP61: 27-Jun-2007 | Hello my teachers. Is there a more elegant way to create a ruler than this in rebol... Str7: Str8: "" Ruler: rejoin [ for Count 10 90 10 [ Str8: rejoin [ Str8 "....+..." Count ] ] for Count 100 250 10 [ Str7: rejoin [ Str7 "....+.." Count ] ] ] print Ruler | |
PatrickP61: 28-Jun-2007 | Hi Anton -- This is my simulated input for a unicode text file: Line1...10....+...20....+...30....+...40....+...50 Line2...10....+...20....+...30....+...40....+...50 If I run this code: InFile: %"Small In unicode.txt" InText: rejoin extract read InFile 2 ; Convert from UNICODE to ANSI but keeps double spacing. OutFile: %"Test Out.txt" write OutFile InText print InText I get these results ˙Line1...10....+...20....+...30....+...40....+...50 Line2...10....+...20....+...30....+...40....+...50 I get them in the output file when I use the Rebol editor, and in notebook (when I open the file) and I get them in console when PRINT InText. | |
PatrickP61: 28-Jun-2007 | Hi Sunanda, -- Thanks for your input on byte order mark. Aside from that would you have any idea as to why the extract will not remove the second A0? See notes above -- here is Greggs suggested code to convert UTF-16: InText: rejoin extract Read InFile 2 ; gets rid of every other byte except newline. | |
PatrickP61: 2-Jul-2007 | Question to all: If I have a block of data inside of In-text like this: Line A Line B Line C How can I print the line number (position in the block) along with the contents of the line? I tried this but it didn't work: foreach Line In-text [ print rejoin [ Count: Count + 1 ] Line ] | |
Group: Rebol/Flash dialect ... content related to Rebol/Flash dialect [web-public] | ||
Oldes: 5-Mar-2006 | but you may use: rebol [ rswf/compile load rejoin [{spr_} spritename {: sprite shp_someshape}]] | |
Oldes: 5-Mar-2006 | but in Actions you can use: now: rebol [ rejoin [ a_block " " now]] | |
Oldes: 5-Mar-2006 | doAction [ info: rebol [now] info: reform [(rebol [rejoin ["h" "e" "l" "l" "o"]]) "now is:" info] ] | |
Group: rebcode ... Rebcode discussion [web-public] | ||
Oldes: 18-Oct-2005 | ints-to-sbs: func[ ints [block!] "Block of integers, that I want to convert to SBs" /complete l-bits "Completes the bit-stream => l-bits stores the nBits info of the values" ;/maxb mb /local b b2 l bits sb ][ ints: reduce ints max-bits: 0 bits: make block! length? ints foreach i ints [ ;b: enbase/base load rejoin ["#{" to-hex i "}"] 2 b: enbase/base head reverse int-to-ui32 i 2 b: find b either i < 0 [#"0"][#"1"] b: copy either none? b [either i >= 0 ["00"]["11"]][back b] ;insert b either i >= 0 [#"0"][#"1"] if max-bits < l: length? b [max-bits: l] append bits b ] foreach b bits [ if max-bits > l: length? b [ insert/dup b b/1 max-bits - l ] ] either complete [ sb: int-to-bits max-bits l-bits foreach b bits [insert tail sb b] sb ][ bits ] ] int-to-FB: func[i /local x y fb][ x: to integer! i y: to integer! (either x = 0 [i][i // x]) * 65535 fb: rejoin [either x = 0 ["0"][first ints-to-sbs to block! x] int-to-bits y 16] if all [x = 0 i < 0][fb/1: #"1"] fb ] | |
Group: !RebDB ... REBOL Pseudo-Relational Database [web-public] | ||
Ashley: 11-Feb-2006 | Thanks guys, I've had a good look at both implementations and I've got ideas from both for a future full JOIN implementation; but at the moment my master/detail code has come along nicely. I've now enhanced the db-select function to accept statements in these additional forms: select * from master joins [select * from details where &id] on id select * from master joins [select * from details where [all [master-id = &id master-date = &date]] on [id date] which works exactly like a normal join with the following differences: a) It can only join one table to another b) Detail columns are always joined to the right of master columns c) Table.column prefixes are not supported so all columns in the join must be uniquely named Apart from that you get all the benefits of db-select (can replace * with specific column combinations, order and group by on the final result set, etc) *and* it's significantly faster than even the raw REBOL code example I gave before (as the SQL is parsed once within db-select and all loop sub-selects are done in-line). I've also implemented “lookups” with the following form: select * from table replaces id with name select * from table replaces [id-1 id-2] with [table-1 table-2] which performs a highly optimized db-lookup for each replaced value, but has the following restrictions: a) The lookup expects lookup tables in the form [id label other-column(s)] b) Only single-key lookups are supported c) A lookup that fails will replace the column value with none! I'm now in the process of benchmarking these changes against sqlite to see where the bottlenecks (if any) are. Feedback on the design decisions is welcome. While I was doing this, I was once again reminded how cumbersome it is to construct SQL statements (not just for RebDB, same goes for the other SQL protocols), as the heavy use of 'compose, 'rejoin, etc adds noise that reduces legibility. The design goal is to provide alternatives to: sql compose/deep [select * from table where [all [col1 = (val1) col2 = (val2)]]] so for a start the 'sql function should probably accept a string, to allow: sql join “select * from “ table type constructs; but this doesn't make the first example easier. So how about the 'sql function accept a block containing a string statement followed by a number of substitution variables, as in: sql reduce [“select * from table where [all [col1 = &1 col2 = &2]]” val1 val2] which makes things a bit more readable (and shortens the expression if longer word names are used multiple times). So the two questions here are: a) Is this a good idea? b) If so, what substitution character (& % $ @ other) will cause the least conflict with REBOL and/or SQL? | |
Coccinelle: 13-Feb-2006 | sql-protocol don't need these heavy use of 'compose, 'join, 'reduce if you use the dialect. Something like this work : var1: "Marco" insert my-db [select * from my-table where name = var1] my-result: copy my-db Another example to ilustrate this : insert my-db [select * from my-table where name like rejoin ["*" var1 "*"]] This is only if you use the dialect to query the database. If you use the standard SQL string, you need to compose the query. | |
Group: SQLite ... C library embeddable DB [web-public]. | ||
Ashley: 13-Feb-2006 | sqlite3-protocol.r has a minor bug whereby locals/cols are not cleared. Fix is to add a "clear cols" at the beginning of the ' sqlite-exec func. Two other changes I made to this function were: 1) Changing “SQLITE_TEXT [any [attempt [load val: sqlite3/column_text stmt j] val]]” so as REBOL values are returned, and 2) Removing the /only clause from "system/words/insert/only tail result col" for those that prefer flat data structures (i.e. non-blocked records) Finally, a simple wrapper makes the whole thing more usable: context [ db: none set 'open-db func [name [file!]] [ db: open join sqlite://localhost/ name ] set 'close-db does [ close db ] set 'describe func ['table [word!]] [ insert db rejoin ["select type, name, sql from sqlite_master where upper(tbl_name) = '" uppercase form table "' order by rootpage"] db/locals/sqlresult ] set 'sql function [arg [string! block!]] [statement] [ case [ string? arg [insert db arg] string? first arg [ statement: copy first arg repeat i -1 + length? arg [ replace/all statement join ":" i pick arg i + 1 ] insert db statement ] ] db/locals/sqlresult ] ] which lets you do stuff like: >> open-db %test.db >> sql "create table t1 (col1 INTEGER, col2 TEXT)" == [] >> describe t1 == [table t1 "CREATE TABLE t1 (col1 INTEGER, col2 TEXT)"] >> sql reduce ["insert into t1 values (1,':1')" now/date] == [] >> sql "select * from t1" == [1 13-Feb-2006] >> close-db | |
Pekr: 22-May-2006 | Ashley - Bobik is getting following error (not so with original sqlite3 protocol): >> sql "select * from kategorie" == [[1 30 34 M30] [2 35 39 M35] [3 40 44 M40] [4 45 49 M45] [5 50 54 M50] [6 55 59 M55] [7 60 64 M60] [8 65 69 M65] [9 70 74 M70] [... >> sql "select * from kartoteka" ** Script Error: Out of range or past end ** Where: sql ** Near: either all [block? v #"[" <> first s] [rejoin v] [v] >> | |
Ingo: 24-Jun-2006 | Does anyone understand this error? >> sql "select * from comm" ** Script Error: Out of range or past end ** Where: sql ** Near: either all [block? v #"[" <> first s] [rejoin v] [v] >> >> sql "select guid from comm" == [[h-o-h.org_20060326_182311681_3176] [h-o-h.org_20060326_182311681_7315] [h-o-h.org_20060326_182311701_2470] [h-o-h.org_2006032 6... >> length? sql "select guid from comm" == 541 >> probe tables ["comm" {CREATE TABLE comm ( guid, type, value, note, flags, keywords, reference, created, updated, deleted )} ;... | |
Pekr: 14-Dec-2006 | uf, following works. Maybe it has something with my nonunderstanding of differences between string/non string values and how to properly insert them ... SQL s: rejoin ["INSERT INTO logs VALUES ('" date "', '" time "', '" ip-address "', '" url "', '" content-type "', '" incident-id "')"] | |
james_nak: 9-Oct-2008 | I found something odd with an app I'm writing. If I insert or update a field (varchar) with a string that has any spaces in it. , it throws a rebol error if I try to select it. For example, I have a string "OK BOb" stored and when I sql {select * from vocab} ** Script Error: OK has no value ** Where: rejoin ** Near: OK BOb It doesn't matter what the first word is. I can't believe I'm the only one so I must be doing something wrong. | |
Ashley: 4-Dec-2008 | Robert, I was thinking we can depreciate the /create refinement by making that implict as well ... and the change required to support additional CONNECTs after the first should be as simple as changing the line that reads: all [dbid sql-error "Already connected"] to something like: if all [dbid file? database] [ unless find file %/ [insert file what-dir] sql rejoin ["attach '" ... return ] which then raises the interesting question as to whether we should force database to be file! (so you'd have to attach multiple databases by issuing multiple CONNECTs ... it would certainly simply the CONNECT logic! ;) | |
BrianH: 22-Dec-2008 | Or REJOIN. | |
amacleod: 22-Dec-2008 | I gues I can build the {select * from fdbooks where ftext like '%ladder%'} string dynamically with rejoin and insert it: srch: {select * from fdbooks where ftext like '%ladder%'} reslts: sql reduce [srch] == [[2 "FFP-LADDERS" "1-PORTABLE LADDERS" "2." " SIZES AND TYPES OF PORTABLE LADDERS IN USE^/" "" 4-Dec-2008/15:29:1 9] [4 "FFP-LADD... | |
Group: reblets ... working reblets (50-100 lines or less) [web-public] | ||
Maxim: 19-Mar-2009 | rebol [ title: "explore.r" version 1.0 date: 2009-03-19 author: "Maxim Olivier-Adlhoch" copyright: "2009(c)Maxim Olivier-Adlhoch" tested: "win xp" notes: "Add any dir to the dirs block. options are self explanatory" ] dirs: [ %/C/ [] %"/C/program files/" [expand] "%tmp%" [label "temp dir"] "" [ label "my documents"] ] blk: [] explore-dir: func [path expand? /local cmd][ call/shell rejoin [" explorer " either expand? ["/n,/e,"]["/n,"] path ] ] ctr: 1 foreach [item opts] dirs [ ctr: ctr + 1 expand?: found? find opts 'expand label: any [select opts 'label to-local-file item] append blk compose/deep [ pad 20 (to-set-word setw: rejoin ["dir" ctr]) check (expand?) pad 20 btn 200 left (label) [ explore-dir to-local-file item get in (to-word setw) 'data ] ] append blk 'return ] view layout compose [across vtext right "expand?" vtext "folder" return (blk)] |
1 / 420 | [1] | 2 | 3 | 4 | 5 |