• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp178
r3wp2151
total:2329

results window for this page: [start: 301 end: 400]

world-name: r3wp

Group: RAMBO ... The REBOL bug and enhancement database [web-public]
Romano:
27-Jan-2005
standard (= load known) rebol words cannot start with a number ('1a 
is not permitted).
Anton:
15-Feb-2005
Who thinks that maybe load parser should be mroe relaxed with paths 
? eg:
>> view-root/public/
** Syntax Error: Invalid path -- public/
** Near: (line 1) view-root/public/
DideC:
25-Feb-2005
>> do http://www.lexicon.net/antonr/rebol/util/demo-request-dir.r
connecting to: www.lexicon.net
Script: "Demo request-dir" (28-Dec-2003)
Script: "scroll-table style" (7-Mar-2004)
Script: "List Sort Button" (10-Dec-2003)
Script: "header-group" (7-Feb-2004)
connecting to: www.lexicon.net

Include: Couldn't load-thru http://www.lexicon.net/anton/rebol/util/request-dir.r
** Script Error: request-dir has no value
** Near: request-dir/initial %./
Anton:
25-Feb-2005
DideC, I moved site. You must update. Do this, then try again:

load-thru/update http://www.reboltech.com/index.r[folder "Anton"]

(and sorry about that - one day soon, all this will not be necessary)
Anton:
27-Feb-2005
Hard to fix though, because I think a LOAD is done on each path element.
Anton:
18-Apr-2005
load-path: func [str [string!] /local result val][
	result: copy []
	foreach component parse str "/" [
		either any [
			error? try [val: load component] ; loaded doesn't parse it
			component <> mold val ; or it looks a bit different
		][
			append result to-word component ; make a "string" word
		][
			append result val
		]
	]
	to-path result
]

load-path {my/path}
load-path {my/path/042}
load-path {my/path/1.s3m}
Anton:
19-Apr-2005
Anyway, now I should try to sink my ship; I don't think adding the 
above functionality (of load-path above) to LOAD would slow things 
down at all. But maybe there are some cases where such allowances 
would cause problems. I am thinking if such a loaded path was converted 
to a block, molded, then loaded again, it would cause the error then. 
That's just moving the load error - from the path to the block. I 
think this contrived case would not occur very often - less than 
using new path notation.
Anton:
20-Apr-2005
OK, submitted a ticket "Load paths in a more relaxed manner".
Anton:
9-May-2005
The error reduces to:
>> load {#"^M"}
** Syntax Error: Invalid char -- #"
** Near: (line 1) #"

Here's another one:

>> load {#"^J"}
** Syntax Error: Invalid char -- #"
** Near: (line 1) #"
Anton:
9-May-2005
(DO first tries to LOAD the decompressed string.)
Anton:
9-May-2005
I think rebol doesn't load #"^M" and #"^J" because they are CR (ascii 
13) and LF (ascii 10).  In rebol, these are molded to #"^M" and #"^/".....
BrianH:
9-May-2005
^M and ^J are newline characters. The syntax of REBOL doesn't allow 
direct newline characters in strings surrounded by " characters. 
In the example you use, the string is read twice - first in the console, 
and then next in the load. Each time the string is read it is unescaped 
(the effects of the ^ char is applied). Since you are unescaping 
twice, you need two ^ characters, the first to escape the second.
Anton:
10-May-2005
^M and ^J (in causing the load error) are exceptional in the alphabet 
of A  - Z.  For example:
	>> load {#"^A"}
	== #"^A"

None of the rest require double-escaping. I am trying to think of 
the reason why rebol treats the newline characters differently.
Gabriele:
10-May-2005
>> load {#"^""}
** Syntax Error: Invalid string -- "
** Near: (line 1) #"""
Anton:
24-May-2005
Yes, Hooray for Romano's FTP!  Just remember to disable your previous 
Romano FTP patch (if you have one) from your user.r.  I added a version 
check around mine:

 if (system/version * 1.1.1.0.0) < 1.2.110.0.0 [ ; View1.2.110 has 
 Romano's FTP handler built in.

  do load-thru site/patch/ftp-romano-patch/ftp-patch53.r  ; the old 
  patch
	]
shadwolf:
3-Jun-2005
For norman new submition bug about error (unrecognised symbol ) when 
loading libraries .so files I have maybe the solution or explanation 
to this problem.... When you look to the error message on loading 
libraries submitted by norman in his post we can see that the problem 
is related to external needed library for example libSDL, libncurse, 
libogg  do not need other libs But  GTK and gthread need previous 
load of glib, libgdk, libpango, libgmodule, libpng, libint, libgtrhread 
and the list is long ;)...
shadwolf:
3-Jun-2005
So before to start to will load htose things you need to know what 
is the library dependencies. On linux you can see the MAKEFILE file 
related to one of the tutorial program integred to the GTK  package 
for example and see the -l*.a entries to have a complete idea of 
the library needed and the order of library dependencies
shadwolf:
3-Jun-2005
I'm agree with the idea that loading complicated heavy splitted and 
many dependent library libs GTK  popup up that we have to seek a 
better library loading system. Dependencies of libraries is a very 
weak point. Think of it ... First you have to load the librariries 
in the dependence chain in the right order and make a rebol script 
file to be able to treat in rebol script code the calls of function 
of those libraries (for example GTK sofware unsed commonly lots of 
function that are builded into many different librairies in the dependencie 
chain (like g_malloc() instead of malloc(), gint type instead  int 
type, gchar type intead of char, g_thread**() instead of  thread**() 
etc...)
shadwolf:
3-Jun-2005
If this fonctionnality remains payant we at most need to rethink 
internally the way to work or build an intermediate library loading 
system script that allows people to load the library without the 
needs of wrtiting by their howns the bridge or a tools that take 
a makefile of a sample program and the include file and generate 
a rebol script bridge for any library that must be loaded to use 
the wanted libraries thos bridges script files must then be supplyed 
as the libraries and the program script in rebol that exploit those 
libraries
Group: Core ... Discuss core issues [web-public]
Volker:
2-Mar-2005
Ammon: "1. It has to be happening during runtime there is no compiling."
load-time and loop-time then? ;)

ammon: "3. If you use a set-word in a context then that word becomes 
part of that context.  If you use SET then it reverts to the context's 
 "parent context" or the context in which the context itself is defined."

Thats the important point: there is no reverting :) and so there 
is no need to keep track of parent-contexts.which is quite clever 
:)
BrianW:
3-Mar-2005
Is there a load path for the 'do function?
DideC:
4-Mar-2005
Isn't what slim does ? Holding paths for code library (scripts) and 
allowing to just slim/load %script-name.r where the file is in one 
of the folder in slim path !!
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
Gregg:
14-Mar-2005
obj-spec: func [
    "Returns the object spec as a single line (flat) string."
    obj [object!]
    /only "no surrounding brackets"
    /mold "Multi-line MOLDed format"
    /local res
][
    res: copy find/tail system/words/mold obj "make object! "
    if not mold [trim/lines res]
    if only [res: trim/auto next head remove back tail next res]
    res
]

remove-words: func [

    "Returns a copy of the object with the specified words removed."
    object [object!]
    words  [word! block!] "The word, or words, to remove"
    /local spec
][
    spec: load obj-spec object
    foreach word compose [(words)] [
        remove/part find spec to set-word! word 2
    ]
    make object! spec
]
Group: Script Library ... REBOL.org: Script library and Mailing list archive [web-public]
Barik:
6-Aug-2009
Hi all. I've got an issue in REBOL2. I have a Win32 DLL (using library/load) 
that has an argument of char**. What does my make routine! need to 
look like to be able to handle this?
Barik:
6-Aug-2009
Hmm, I just realized library group was for the script library, not 
for library/load and DLL related questions. Oops.
Group: Parse ... Discussion of PARSE dialect [web-public]
Chris:
30-Jan-2005
It may be a recurrence of a problem parsing " at the beginning of 
a line -- doesn't seem to be a problem on the beta that I have open 
(1.2.54).  As an alternative, you could always read/lines, or simply 
load the file...
Group: MySQL ... [web-public]
Sunanda:
25-Feb-2005
Apologies on Insert -- I'd assumed from the fact you'd asked the 
question that MySQL did not support the Values syntax.


Update is trickier as you are potentially changing a whole load of 
values.

Best way is to have the update data in a 2nd table, and then select 
as appropriate.
MikeL:
16-Sep-2005
This is related, I think, to my notes about VID and MySQL in the 
View section. In a test that we ran in 2004 we were able to load 
1,000,000 rows in under 30 minutes.  We did not investigate further 
but we thought we could improve this by running parallel loads and 
putting it on a real server instead of a laptop.  This volume was 
equal to the annual volume of  the transactions we were interested 
in so would represent a journal of everything that happened to this 
app as a keyed transaction in one year.   


From that 1,000,000 row database, we were able to create an HTML 
report based on some selected criteria in 2.5 seconds.  

All tests done with REBOL View using Doc's mySQL protocol.
Pekr:
9-Jan-2006
Doc, are you sure your 'docode table is ok? I mean defs/client ....

client [
			long-password		1		; new more secure passwords
			found-rows			2		; Found instead of affected rows
			long-flag			4		; Get all column flags
			connect-with-db		8		; One can specify db on connect
			no-schema			16		; Don't allow db.table.column
			compress			32		; Can use compression protcol
			odbc				64		; Odbc client
			local-files			128		; Can use LOAD DATA LOCAL
			ignore-space		256		; Ignore spaces before '('
			change-user			512		; Support the mysql_change_user()
			interactive			1024	; This is an interactive client
			ssl					2048	; Switch to SSL after handshake
			ignore-sigpipe		4096	; IGNORE sigpipes
			transactions		8196	; Client knows about transactions
		]

While in protocol description, there is:

MySQL uses the following codes:
Capability name	Value	Meaning
LONG_PASSWORD	1	New more secure passwords
FOUND_ROWS	2	Found instead of affected rows
LONG_FLAG	4	Get all column flags
CONNECT_WITH_DB	8	One can specify db on connect
NO_SCHEMA	16	Don't allow database.table.column
COMPRESS	32	Can use compression protocol
ODBC	64	ODBC client
LOCAL_FILES	128	Can use LOAD DATA LOCAL
IGNORE_SPACE	256	Ignore spaces before '('
PROTOCOL_41	512	Support the 4.1 protocol
INTERACTIVE	1024	This is an interactive client
SSL	2048	Switch to SSL after handshake
IGNORE_SIGPIPE	4096	IGNORE sigpipes
TRANSACTIONS	8192	Client knows about transactions
SECURE_CONNECTION	32768	New 4.1 authentication
MULTI_STATEMENTS	65536	Multi-statement support
MULTI_RESULTS	131072	Multi-results
Dockimbel:
14-Jan-2006
I have plans for a version 2 of this driver including a full code 
rewritting for much cleaner design, speed improvements, optional 
async API, support more protocol features (like LOAD DATA), implement 
the v5 protocol, improved user API (e.g.: select column in a record 
by field name), etc...
Dockimbel:
11-Jun-2006
1) Load the REBOL mysql console : do %mysql.r
2) Connect to the server
3) Command: show tables
4) result ok
5) Stop/Start the server
6) Command: show tables
7) result ok (the driver has reconnected transparently)
Group: Linux ... [web-public] group for linux REBOL users
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
] 

]
Ladislav:
9-Apr-2007
Max, why don't you use LOAD in PARSE, if you want to? Example:

rule: [
	(result: make block! 0)
	any [
		[
			; trying to load
			pos: skip (
				next-rule: either error? try [
					set [value pos] load/next pos
				] [[end skip]] [[:pos]]
			) next-rule |
			; load didn't succeed, using something else
			copy value skip
		]
		(insert/only tail result get/any 'value)
	]
]

>> parse "1 2 a, 3" rule
== true
>> result
== [1 2 "a" "," 3]
Maxim:
9-Apr-2007
well, its not that we can't right now... like you show, load can 
be called anywhere.


 (though I am going to admit I would not have figured out such an 
 elegent way to do it, *I* am not yet able to use the force... <ahem> 
 parse with such skill, MASTER JEDI  ;-) ... 


but did you see how much is needed to make that work and the twist 
of redefining a rule within the evaluated expression?  parse is supposed 
to scream in speed... having a load directive integrated would be 
MUCH faster IMHO, and would be MUCH simpler for the new guys on the 
block and us oldies too...  try to explain the above to the average 
joe and well... there goes the parser...  I only 'SEE' your example 
cause I've become able to fit parser in my mind, and I realize that 
even within the advanced REBOLer crowd... not everyone really grasps 
the parser...


one question though, does the set [value pos] define the word globally 
even if the entire above code is within a context which has a value 
and pos defined?
Micha:
13-Apr-2007
Core not load image.png
btiffin:
16-Apr-2007
And I guessed that libc.so  was  libc.so: load/library %/lib/libc.so.6
Louis:
3-May-2008
But rebolview for Debian does not load on my Kubuntu machine.  Well, 
actually it loads, but after I give my user info it dies and won'
Louis:
3-May-2008
t load again.
Group: !Readmail ... a Rebol mail client [web-public]
PhilB:
10-Jan-2005
rebmail 4.7.14 & associated helptext has been released (31/12/2004) 
...

Changes Since 4.7.11
Enhancement - re-work locale format (for security purposes)
Bug Fix - Correct Fetch All Error
Enhancement - Use load/all & Construct to load locale from file


rebmail.r can be found at .... http://www.upnaway.com/~philb/philip/pbmail/readmail.r

reabmail is also the following formats 

rip format at  .... http://www.upnaway.com/~philb/philip/pbmail/readmail.rip

zip format at  .... http://www.upnaway.com/~philb/philip/pbmail/readmail.zip


the archive containing rebmail.r & rebamail.html (rip = compressed 
self extracting rebol archive)
 
Any problems let me know.
PhilB:
10-Jan-2005
rebmail 4.7.14 & associated helptext has been released (10/01/2004) 
...

Changes Since 4.7.11

4.7.12 - Enhancement - re-work locale format (for security purposes)
4.7.13 - Bug Fix - Correct Fetch All Error

4.7.14 - Enhancement - Use load/all & Construct to load locale from 
file


rebmail.r can be found at .... http://www.upnaway.com/~philb/philip/pbmail/readmail.r

reabmail is also the following formats 

rip format at  .... http://www.upnaway.com/~philb/philip/pbmail/readmail.rip

zip format at  .... http://www.upnaway.com/~philb/philip/pbmail/readmail.zip


the archive containing rebmail.r & rebamail.html (rip = compressed 
self extracting rebol archive)
 
Any problems let me know.
Group: SDK ... [web-public]
DideC:
23-Feb-2005
Question: the SDK license require to not let the program interpret 
Rebol code !

If the program load a config file (with 'construct) does it go against 
the license or not ?
sqlab:
11-Apr-2005
I use this for window titles

win-lib: make object! [
	
	user-lib: load/library %user32.dll

	SetWindowText: make routine! [
		handle			[integer!]
		Title			[string!]
		return:			[integer!]
	] user-lib "SetWindowTextA"
	
	set 'WindowTitle: func [
		Title [string!] 
	] [
		SetWindowText get-modes system/ports/system 'window Title
	]
	
]
sqlab:
11-Apr-2005
It works for all console windows of Rebol, if you can load a .dll
Micha:
10-Oct-2005
kernel-lib: load/library %kernel32.dll
WriteFile: make routine! [
        hFile                   [integer!]
        lpBuffer                [integer!]
        nNumberOfBytesToWrite   [integer!]
        lpNumberOfBytesWritten  [integer!]
        lpOverlapped            [integer!]
        return:                 [integer!]
 
    ] kernel-lib "WriteFile"
Group: !Uniserve ... Creating Uniserve processes [web-public]
DideC:
9-Mar-2005
In short.

Protocols and services (or whatever else) are encapped as data in 
a block! (a cache sort-of).

instead of 'do/'load, you have to use 'do-cache/'load-cache in your 
script.


The cache functions are initialize differently either you are encapping 
or doing the script.
DideC:
9-Mar-2005
Rebol [

 title: "example of starter script that act the same with View after 
 encap"
]

#include %/e/rebol/sdk/source/mezz.r
#include %/e/rebol/sdk/source/prot.r
#include %/e/rebol/sdk/source/view.r

;***** This is the function that make the tricks
#include %uniserve/libs/encap-fs.r 
if not value? 'encap-fs [do %uniserve/libs/encap-fs.r]

set-cache [
	%uniserve/uni-engine.r		[#include %uniserve/uni-engine.r]
	%uniserve/libs/headers.r	[#include %uniserve/libs/headers.r]
	%libs/log.r					[#include %uniserve/libs/log.r]
	%uniserve/protocols/HTTP.r	[#include %uniserve/protocols/HTTP.r]
	
	%your-file.r					[#include %path/to/your-file.r]
	;...
]

;***** Start
do-cache %uniserve/uni-engine.r
do-cache %uniserve/libs/headers.r

UniServe-path: %./uniserve/
logger/level: none


;***** You have to load protocols and services before starting Uniserve
do-cache %uniserve/protocols/HTTP.r

;***** Uniserve Initialise
; Require like this to not loading protocols/services from disk
uniserve/boot/no-loop/with []

;***** Your script initialise
;...
DideC:
9-Mar-2005
encap-fs: context [
	cache: path: none
	root: system/script/path

	get-cache: func [file][
		path: parse file "/"	
		remove-each dir path [dir = ".."]
		file: to-file path	
		either file [
			either file: select cache file [file][load file]			
		][
			make error! join "Cannot access : " file
		]
	]
	
	set 'encap? to-logic select system/components 'decap

	either encap? [
		set 'set-cache func [list [block!] /local bin file][
			cache: list
			;cache: make block! 16
			;parse list [
			;	some [
			;		(bin: no) opt ['binary (bin: yes)]
			;		set file file! (
			;			repend cache [
			;				file
			;				either bin [read/binary file][read file]
			;			]
			;		)
			;	]
			;]
		]
		set 'do-cache func [file [file!]][do get-cache file]
		set 'load-cache func [file [file!]][load first get-cache file]
		set 'read-cache func [file [file!]][]
	][
		set-cache: none
		do-cache: :do
		load-cache: :load
		read-cache: :read
	]
]
MikeL:
17-May-2005
From the documentation, "Uniserve's purpose is to offer a simple 
but powerful solution for programming client and servers applications 
that can be combined with View interfaces easily."


The uses for the Asynch that I can come up with are: 1. Backup after 
transactions. 2. Journalizing / reporting after a committed transaction 
update 3. Database access 4. Queuing of side-effect events that are 
not needed for the response in the user interface. 


Aside from that, my understanding is that an synch event could be 
made asynch to allow a lower end server to process the workload.

Does anyone have any other uses from the 4 noted?


Does anyone have a simple sample of tying Uniserve into the View 
interfaces?


Are there any results of driving some load using uniserve versus 
synchronous or other solutions like threaded models?




I am trying to get my head around this a bit more and want to rely 
less on the Doc-likes-it-some-it-must-be-the-right-thing-to-do approach 
that I have used before.


I read the Medusa documentation that Doc refers to but it did not 
lead me to any good application examples.
Terry:
4-Feb-2006
And if I LOAD the external file, you would think it would bind it 
all globally, but it doesn't?
Terry:
4-Feb-2006
Ok.. so now I can run the external script by placing waiting till 
i finsh the external, and get back to the 'on-received' function... 
but I have a number of functions that I use to process my external 
script.. 
Do I need to load those functions with every on-received event???
Group: XML ... xml related conversations [web-public]
Maxim:
24-Jun-2009
>> probe load replace {#[object! [a: #[object! [b: #[object! [c: 
"%VALUE%"]]]]]]} "%VALUE%" "tadam!"
make object! [
    a: make object! [
        b: make object! [
            c: "tadam!"
        ]
    ]
]
Maxim:
24-Jun-2009
my client has a few thousand data types to cope with ;-) rebxml allows 
you to load that up pretty quickly...but not using the xsd obviously.


its parser builds up a string and then loads it.   I found it to 
be quite fast actually.  its MUCH faster than firefox, for example.
Maxim:
24-Jun-2009
you can just do a mold/all load, that will in effect copy the whole 
tree along with all the series too.
Maxim:
24-Jun-2009
ex:

load mold/all make object! [
    a: make object! [
        b: make object! [
            c: "tadam!"
        ]
    ]
]


will effectively create a complete duplicate of the whole object 
tree.
Graham:
24-Jun-2009
So, I can continue to make the objects as I have been doing.  But 
just before I use it ... I load mold/all on it to ensure I have unique 
objects
Graham:
24-Jun-2009
ie. I load a serialized form of the object
Graham:
24-Jun-2009
seems not :(

>> pharmacy: make object! [
[     name: none
[     init: func [ n ][
[          self/name: n
[         ]
[    ]
>> a: load mold/all make pharmacy []
>> probe a
make object! [
    name: none
    init: func [n][
        self/name: n
    ]
]
>> a/init "testing"
** Script Error: self has no value
** Where: init
** Near: self/name: n
Maxim:
24-Jun-2009
if you have a function inside, I think you have to do it instead 
of load it.
Graham:
24-Jun-2009
so, I have to  now do

a: do load mold make pharmacy [ ]  ?
Sunanda:
24-Jun-2009
Do has some dangers if you do not trust the code involved. This works 
for me, and keeps the load/all (but not the self).....Even more tortured:
   a: first reduce load/all mold pharmacy
Sunanda:
24-Jun-2009
You may have some other issues to consider as part of building/loading 
the data structures.

For example, Version2 of the application adds some fields  not present 
in V1.

To avoid a one-off bulk conversion exercise, the load process needs 
to check each object and add missing fields with default values.
Chris:
12-Aug-2009
>> do http://www.ross-gill.com/r/altxml.r
connecting to: www.ross-gill.com
Script: "AltXML" (7-Jun-2009)
>> all-stats: load-xml/dom your-xml-data 
>> player: stats/get-by-id "b.11965"                        
>> his-stats: first player/get-by-tag <stats-baseball-offensive>
>> his-stats/get #hits                                          
== "1"


>> remove-each code codes: all-stats/get-by-tag <sports-content-code> 
["league" <> code/get #code-type]
== [make object! [
        name: <sports-content-code>
        space: none
        value: [
            #code-type "league" 
      ...
>> foreach code codes [probe code/get #code-name]
Major ^/      League Baseball
== "Major ^/      League Baseball"
Chris:
14-Aug-2009
>> google-xml: load-xml/dom clipboard:// ; copied from page
>> entries: google-xml/get-by-tag <entry>
== [make object! [
        name: <entry>
        space: none
        value: [
            #etag {"BxAUSh5RAyp7ImBq"} 
            <...
>> foreach entry entries [probe entry/get <resourceId>]
spreadsheet:key
== "spreadsheet:key"
Pekr:
4-Jan-2010
I like SAX model, because IIRC it allows to work on things in a "streamed" 
way, whereas DOM requires you load everything in memory? Sorry if 
I oversimpilifed it :-) IIRC Doc used such aproach in his Postgress 
SQL driver, in opposite to his mySQL one ...
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]
]
Vincent:
23-Jun-2005
Oops too fast: 

commands Q S T -> OK

commands H &t V -> need to add (just before "foreach token load val 
[") :
if all [x not number? token] [
    insert tail shape x * either token = 'V [scale-y][scale-x]
    x: none
]
command A -> not yet solved sign issues
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]
]
Ashley:
23-Jun-2005
Thanks for taking this up and running with it guys, you're making 
great progress (far better than I could have). Feel free to take 
ownership of the code and refactor it as needed.

Two minor improvements are:

	unless closed? [insert tail shape reduce ['move 0x0]]

which is Gabriele's fix to the shape close problem, and:

	feel: make feel [
		redraw: func [face act pos] [

   if act = 'draw [insert clear face/effect/draw load-svg face/data 
   face/size]
		]
	]


which cleans the sample feel code up a bit. I'd also remove "VID" 
from the title of this group as DRAW AGG is tied to View. ;)
shadwolf:
30-Jun-2005
in this file we have xml-to-object function load-svg function (mostly 
empty there is where to put the data conversion and draw block construction) 
and the widget that start the program
shadwolf:
2-Jul-2005
try to load all the files that Ashley provides with his svg-demo
Group: AJAX ... Web Development Using AJAX [web-public]
Oldes:
28-Mar-2006
I still don't understand why so many people are so excited with Ajax, 
from my point of view it's just the getXMLHttpRequestObj() function, 
which started to work after many years in more than one browser, 
and which enable us to load something without need to reload all 
the page.
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
Ashley:
13-Feb-2006
I will once they've settled down ... the SQLITE_TEXT change mentioned 
previously should read:

	SQLITE_TEXT [
		val: sqlite3/column_text stmt j
		any [
			all [
				attempt [tmp: load val]
				not block? tmp
				not word? tmp
				tmp
			]
			val
		]
	]


which should correctly handle TEXT with embedded white-space or illegal 
load chars. The context of funcs can also have the following useful 
func added:

	set 'sql-columns does [
		copy db/locals/cols
	]


and should probably 'copy return db/locals/sqlresult in both the 
'sql and 'describe functions.
Ashley:
15-Feb-2006
As I mentioned near the beginning of this thread, SQLite supports 
multiple database files each containing one or more tables - in fact 
they go so far as recommending that you separate multiple high-access 
tables out into different databases for concurrency reasons. In this 
sense, SQLite "databases" act more like traditional "tablespaces". 
So, if we wanted we could write our REBOL front-end so that it created/accessed 
each table in a database of the same name thus ensuring a one-to-one 
mapping between table names and database names. The advantages of 
this approach are:

	backups (only those tables that change need be backed up)

 external table administration (you can drop a table by deleting its 
 database file)

 concurrency (you spread your file locking across a greater number 
 of physical files)

Disadvantages:


 Administering your database is more cumbersome (you can't use the 
 sqlite3 admin tool to administer all tables in one session)

 Value of sqlite_master is diminished (you can't "select * from sqlite_master" 
 to report on all your tables in one query)

 Query references need to add a database prefix when referring to 
 a table not in their own database

 Name conflicts (all tables in one file means multiple databases can 
 use the same table names - the solution with multiple files would 
 be to segregate at the directory level)

 Multiple database files means you need to zip them prior to some 
 operations such as email attachment, etc


On balance, I actually prefer the one file / one database approach.


Pekr's other comments in relation to schema implementation also have 
merit (I've agreed with Pekr twice today - a new record!); I see 
the value of an ftp schema, an http schema, etc; but what value in 
a sqlite schema? Given that the entire schema can be written in a 
much more concise fashion as an anonymous context that exports a 
couple of key access functions to the global context; I can't see 
what the functional differences between the two implementations would 
be?


So, bar any good reasons to the contrary, these are the features 
of the implementation I am currently working on (a rough design spec 
if you like):

	Implemented as an anonymous context

 "Database" is a directory (which is specified when a database is 
 opened with 'open-db)

 Each table resides in a "tablespace" (aka SQLite database file) of 
 the same name
	File is automatically opened on first reference

 The /blocked refinement of 'db-open specifies that rows will be returned 
 in their own block (default is a single block of values)

 Non-numeric values (which SQLite stores natively as INTEGER and REAL) 
 will be subject to 'mold/all on insert and 'load on retrieval

 The /native refinement of 'open-db will turn this behaviour off (see 
 comments below)

 SQLite binding will be supported allowing statements such as ["insert 
 into table values (?,?,?)" 1 [bob-:-mail-:-com] "Some text"] and ["select 
 * from table where email = ?" [bob-:-mail-:-com]]


Whether to store values (including string!) as molded values in SQLite 
is an interesting question; on the one hand it gives you transparent 
storage and access to REBOL values – but at the performance cost 
of having to mold and load every TEXT value returned; and the storage 
cost of the overhead of a molded representation. On the other hand, 
if I only want to store numbers and strings anyway then I don't want 
this overhead. I think the only practical solution is a /native type 
option as detailed above.
Ashley:
16-Feb-2006
I've given up on the one table per database idea as the default attachment 
limit is 10 files. On the positive side, the ATTACH command seems 
to work properly under 3.0+ and table names unique to an attached 
database do not have to be prefixed in queries. ;) My 'connect function:

>> help connect
USAGE:
    CONNECT database /create /attach databases /blocked /direct

DESCRIPTION:
     Open a SQLite database.
     CONNECT is a function value.

ARGUMENTS:
     database -- (Type: file url)

REFINEMENTS:
     /create -- Create database if non-existent

     /attach -- Attach up to 10 databases (of type file!) to this connection
         databases -- Database files (Type: block)
     /blocked -- Return each row as a block
     /direct -- Do not mold/load REBOL values

lets you do this:


 connect/attach %/c/app/data/system.db [%/c/app/data/users.db %/c/app/data/reports.db]
	sql "select * from a-system-table"
	sql "select * from a-user-table"
	sql "select * from a-report-table"


which could be quite useful in many situations. The default, however, 
is now one database.


BTW, my rewrite (even after adding a lot more functionality) is about 
twice as fast as the original protocol version.
Anton:
9-Mar-2006
He might be doing this :
	context load %script
Gabriele:
14-Mar-2006
notice that encap does a mold/flat load on the script too
Gabriele:
14-Mar-2006
does   do mold/flat load %sqlite.r    still work?
Ashley:
20-Mar-2006
Graham, yes to all the above except timestamp/date fields. SQLite 
only supports 5 datatypes: Integer, Decimal, Binary, Null and Text. 
The driver (unless using the /direct refinement to connect) MOLDs 
and LOADs other REBOL types such as date!, pair!, etc into SQLite 
TEXT fields so date is certainly supported at the REBOL level (although 
an "order by date" clause will not give the expected results ... 
I tend to use 'sort/skip SQL "select id,date from t" 2' type constructs 
to achieve the desired result).


Given how common this later operation is (order by date) I'm looking 
at changing the way date is bound. Instead of just MOLDing it, if 
it is transformed to YYYY-MM-DD format then not only can LOAD recognize 
it but it can be sorted (as TEXT) directly by SQLite.
Pekr:
21-Mar-2006
Ashley - the question is, if there should be any delimiter in DB 
:-) You can write simple copy/part at .... if you want .... and load 
will load it into rebol format anyway, no?
Ashley:
21-Mar-2006
Pekr, "the question is, if there should be any delimiter in DB". 
There has to be, otherwise LOAD will treat "20060101" as an integer 
not a date. Remember that SQLite has no concept of "column types" 
so the MOLDed values themselves have to carry / represent the REBOL 
type when LOADed. What we are trying to do with date is to use an 
alternate representation that REBOL will still recognize as a date 
but that also happens to sort correctly; YYYY-MM-DD achieves both 
those objectives, it's just a cosmetic question as to what delimiter 
"looks" better if someone looks at the raw data (prior to being LOADed 
into REBOL values) or uses the format directly in their statements 
(e.g. "select * from t where date = '2006-01-01'").


Graham, "If they are stored as numbers, then just as easy to sort!" 
Yes, but as per above we lose the fact that they are dates. If they 
are stored as integer then we'll get them back as integers.


Graham, "what about time?" REBOL time values (in HH:MM:SS format) 
are already supported, and nothing prevents you from using now / 
now/precise except that these values will not be sorted correctly 
[with an "order by" clause that is].
Ashley:
21-Mar-2006
Mind you, I can always extend the date handling logic (as posted 
previously) to check to see whether the date has a time component; 
something like:

	if val/time [...]


Should we be checking for a zone component as well? The shortest 
possible timestamp that REBOL will recognize is:

	type? load "2006-01-01/13:30"

But that excludfes both seconds and zone.
Robert:
23-Mar-2006
Is the linking between SQLite and RebGUI already implemented? In 
that if I get back a result set, that I can use it directly to fill 
a list or drop-down list? Or load a result set into a form?
Ashley:
25-Mar-2006
Replace the column-text block in the SQL function with:

	[(
		either direct [
			[*column-text (sid) idx]
		][
			[
				s: v: *column-text (sid) idx
				while [s: find s {""}] [change/part s "" 2]
				load v
			]
		]
	)]

I've added this to the next build.
Ashley:
26-Mar-2006
Direct: definite speed gain as MOLD / LOAD is bypassed for each and 
every value bound / retrieved. /flat (if your data structure can 
use it) is also faster and uses less memory - although the gain is 
more noticeable with larger numbers of rows.
Ashley:
7-Apr-2006
If it's only TEXT types you need to encrypt then we could always 
add a /secure refinement to CONNECT that would force encrypt / decrypt 
on all TEXT bind variables. Performance wouldn't be too bad as values 
would only be encrypted [once] on INSERT and SELECT, the actual query 
(which could potentially hit millions of rows) would be comparing 
encrypted strings and would only need to decrypt strings that form 
part of the result set. Very similiar to the overhead that MOLD/LOAD 
currently incur when not using the /direct refinement.
Group: Postscript ... Emitting Postscript from REBOL [web-public]
Ryan:
5-Apr-2006
I lean toward PDF too, but the dialect is not much fun to use, it 
can take a long time to load, and you have to preview it before printing, 
not too mention versioning issues. Thats why I had been looking for 
a BMP printing solution. I was considering using PS for printing 
only images directly to printers, which would still be nice--mainly 
for non-win OS's. I think this would be much easier to impliment. 
I dont know squat about post script, but it could potentially be 
just a hack.
Group: Plugin-2 ... Browser Plugins [web-public]
Volker:
17-May-2006
Or you could download an html-file into the sandbox and the user 
opens it locally by explorer. I guess the plugin would then load 
from the filesystem too. But not sure.
Volker:
17-May-2006
Its just like the dekstop-sandbox, only on another place. You should 
find that dir by showing 'what-dir. And then just write the html-file 
there, load-thru may do the trick.
Anton:
18-May-2006
Yes, see source of PATH-THRU.  Instead of using DO, LOAD and EXISTS?, 
 use DO-THRU, LOAD-THRU and EXISTS-THRU? They all use PATH-THRU.
Brock:
18-May-2006
Maybe using the load-thru or read-thru here would have resolved this? 
 I haven't used those commands much so not certain exactly how the 
-thru commands work and where to use them... I'll read the source 
as suggested by Anton.
Volker:
18-May-2006
No, they are just 'load with download.
Volker:
18-May-2006
would save code, if you did not need to change the file. Then
  load-thru url-of-online-html
would do the trick.
BrianH:
15-Jun-2006
read-thru, load-thru, etc., just like View uses for its sandbox.
Group: !GLayout ... ask questions and now get answers about GLayout. [web-public]
Graham:
21-Sep-2006
So, if it resides on the local drive, and you load it each time .. 
you're okay?
Group: !CureCode ... web-based bugtracking tool [web-public]
Dockimbel:
8-Feb-2009
Cheyenne server upgraded again. The new on-the-fly RSP output compression 
should make RSP pages loading 2x faster on average than before (but 
you may not noticed as CC pages load already very fast)
BrianH:
11-Apr-2009
The value="" disables saved passwords. I don't want to have to load 
up my password database if I am on a trusted computer that I can 
just let the browser track my passwords.
Group: reblets ... working reblets (50-100 lines or less) [web-public]
Ammon:
1-Apr-2009
REBOL [
	File: %scramble.r
	Author: "Ammon Johnson"
	Email: [ammon-:-johnson-:-gmail-:-com]
	Version: 0.0.1
	History: [
		0.0.1 31-Mar-2009 "scrambles and descrambles code"
	]
]

scramble: context [
	words: []
	load-words: does [
		foreach word first system/words [
			add-word mold word
		]
	]
	add-word: func [
		word
		/local chars length
	][
		chars: charset word
		unless found? find words chars [repend words [chars copy []]]

  unless found? find words/:chars length: length? word [repend words/:chars 
  [length copy []]]
		length: select words/:chars length
		unless found? find length word [insert tail length word]
		word
	]
	get-word: func [
		word
		/local chars length
	][
		chars: charset word
		unless chars: select words chars [return "UNKNOWN"]
		unless length: select chars length? word [return "UNKNOWN"]
		random/only length
	]
	scramble: func [
		txt
		/local result
	][
		result: parse/all txt " "
		forall result [

   unless empty? trim copy result/1 [change result random add-word result/1]
		]
		form result
	]
	
	descramble: func [
		txt
		/local result
	][
		result: parse/all txt " "
		forall result [

   unless empty? trim copy result/1 [change result get-word result/1]
		]
		form result
	]
]
301 / 2329123[4] 56...2021222324