r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Sunanda
19-Oct-2010
[103]
Actually, I think a pre is closer to heredoc than CDATA.
CDATA is strictly speaking for XML or XHTML. not HTML.

And CDATA only, in effect, protects unescaped <, > and & from being 
interpreted as mark-up.

Perhaps, more importantly for the heredoc issue, whitespace is not 
guaranteed to be left as-is in CDATA:
   http://www.w3.org/TR/html4/types.html#h-6.2
But it certainly does not matter to me what we call it :)
GrahamC
21-Oct-2010
[104x2]
Regarding order of function parameters ... eg.  REPLACE target search 
replace /all /case /tail


it's probably not as intuitive to read ... but if you had  REPLACE 
search replace target /all /case /tail

this would aid processing the output of other functions

So, instead of 


replace some series of functions here which returns a string but 
I've got to end this stream with replace target

I could do


replace  replace target   some series of functions here which returns 
a string but I've got to end this stream with
with the aim of passing the output of one function to another in 
a chain
Anton
21-Oct-2010
[106]
Graham, I agree.
GrahamC
21-Oct-2010
[107]
Or, how about a switch that allows you to change the order of the 
arguments?
Gregg
21-Oct-2010
[108]
Then you might want to change all the other funcs that take the target 
series as their first arg as well. 

I'm OK with the existing arg order.
Robert
23-Oct-2010
[109]
Any short hint, how I can use an http URL like: www.domain.com/script`?par1="abc"?par2=123
Sunanda
24-Oct-2010
[110]
Something like this?
    domain: http://www.domain.com/script`
    parameters: {par1="abc"?par2=123}
    reply: read/custom domain compose [GET (parameters)]
Robert
24-Oct-2010
[111]
Thanks, I will try it.
james_nak
24-Oct-2010
[112]
o: context [test: 123]
append h o
n: context [n2: context [h]]

Above is just a concept of what I want which is to create an object 
with an object that contains the object(s) held within h block. I've 
tried compose/deep binds and just about everything else I could think 
of.

The context of this is I have created objects which are held in a 
global block represented by h. I then have to  put these all together 
as one object. I just can't get rebol to do that. I always get a 
rather empty object.
Sunanda
24-Oct-2010
[113]
Does this do it?
    h: copy []
    o: context [test: 123]
    append h o
 
    n: context []
    foreach entry h [n: make n entry]
james_nak
24-Oct-2010
[114]
Thanks Sunanda. I'll try that. Carl was just here looking at the 
code (How humiliating) and telling me why mine wouldn't work. OOPs.
Sunanda
24-Oct-2010
[115]
Wow, you had a lesson from the master!
Remember to add a comment to the final code:
     Designed in collaberation with: Carl Sasserath.
james_nak
24-Oct-2010
[116]
:-) It was more like "you call yourself a reboller?"
Maxim
24-Oct-2010
[117]
hehe... let me guess, you had objects, which had methods?   ;-D
james_nak
24-Oct-2010
[118]
No it was like the stuff above.
Sunanda
24-Oct-2010
[119]
See Wagner / Tannhäuser. anectdote: 
    http://www.workjoke.com/musicians-jokes.html
james_nak
24-Oct-2010
[120]
Yes, that's me.
Gregg
24-Oct-2010
[121]
On Windows 7, is there a known reason that REBOL, doing a read %., 
would not return all the files in a dir? I can only think security/permissions 
are at play somehow. I need to test more, but as a quick test, you 
could open windows/system32/ in explorer and look at its file count, 
then do a READ on that dir and see if you get a different result.
GrahamC
24-Oct-2010
[122x2]
This is my attempt at a function that returns the object or value 
at the end of the given path.  If there is nothing at the given path, 
it returns none.

  get-obj-value: func [ obj [object!] path [path! word!]
        /local id 
    ][  
        if word? path [ path: to-path path ]
        either not empty? path [
            either all [ 
                id: in obj path/1  
                obj: get id 
            ][
                either 1 = length? path [
                    return obj
                ][
                    either object? obj [
                        get-obj-value obj remove copy path
                    ][
                        return none
                    ]
                ]
            ][
                return none
            ]
        ][ obj ]
    ]

improvements appreciated
The reason for this is I am converting deeply nested xml into rebol 
objects and I don't know what the final object will turn out to be 
....
Ladislav
25-Oct-2010
[124]
Hi, solving a problem with file! values in different filesystems. 
I need to handle case-insensitive filesystems differently, than the 
case-sensitive ones. Does REBOL already offer the information, whether 
the filesystem in question is case-sensitive?
Sunanda
25-Oct-2010
[125]
Not as far as I know,
You could probe the system like this:
    write %tmp "one length"
    write %TMP "another length"

    either (get in info? %tmp 'size) = (get in info? %TMP 'size) ['insensitive]['sensitive]
Ladislav
25-Oct-2010
[126]
Yes, that is what I was afraid of. (this is problematic, if you are 
not allowed to create new files) OK, Robert and I have agreed, that 
we keep INCLUDE case-insensitive (for file comparisons), and put 
the information into the documentation.
Henrik
25-Oct-2010
[127x3]
Ladislav, how about reading the root directory, find a camel-cased 
file, lower/uppercase it and ask if the file exists?
of course depending if the file doesn't happen to exist.
(not totally reliable)
Ladislav
25-Oct-2010
[130x2]
again, this may not work if you are not allowed to read the root 
directory
nevermind, the solution we use for INCLUDE looks like sufficient, 
I will document how it works.
Henrik
25-Oct-2010
[132]
I guess also it's a problem for networked drives. The file sharing 
mechanism might offer incorrect information as to what the case sensitivity 
for the file system being shared, is.
Ladislav
25-Oct-2010
[133]
Right, it is a complicated matter, that is why it looks better to 
use an "acceptable" solution instead of trying to implement a "perfect" 
solution
Sunanda
25-Oct-2010
[134]
Could you try a variant on....
    all [exists? uppercase what-dir exists? lowercase what-dir]

....At least it does not require reads/writes outside of the current 
folder.
Ladislav
25-Oct-2010
[135]
That is possible, but, unfortunately, not perfect as well. (Does 
not solve the case when the file system is case-sensitive, but contains 
both upper as well as lower case variants)
Sunanda
25-Oct-2010
[136]
What I meant to write was:

all [exists what-dir? exists? uppercase what-dir exists? lowercase 
what-dir]

Plus then you need to check if info? is the same on all three.

I think that covers your case......But is not perfect either .... 
It fails If the what-dir path happens to contain no case sensitive 
characters.

It's tricky!
Ladislav
25-Oct-2010
[137]
Agreed
PeterWood
25-Oct-2010
[138]
Can't you infer whether the file system is case sensitive, case insensitive 
 or case insenstive but case preserving from system/version?
Henrik
25-Oct-2010
[139]
not if the includes are grabbed from a network resource, such as 
when running your R3 in a VM inside another OS and the source is 
stored in that other OS.
Maxim
25-Oct-2010
[140]
actually there is a way to know if the destination filesystem is 
case sensitive, but it requires a write operation.
PeterWood
25-Oct-2010
[141]
Thanks for the explanation, Henrik.
Maxim
25-Oct-2010
[142x2]
you write two files with different case, using different data.  then 
read the first one, and making sure it doesn't give you the value 
of the second.
hehe... just saw sundanda's original post... which basically a play 
on my above post... it was out of scroll on my view.
Izkata
25-Oct-2010
[144]
Ladislav: I was going to suggest something similar as Sunanda, except 
by using [sort read %.] instead of [what-dir], then checking the 
first file with alphanumeric characters.  That way, if both upper 
and lowercase do exist separately, they'd show up in the list and 
can be adjusted for
Sunanda
25-Oct-2010
[145]
Can you not assume, Ladislav, that you will have read access to user.r?
And use reads/info? for variants on that to check?
james_nak
25-Oct-2010
[146]
Graham, did you figure out the object issues? And are you using or 
have you tried the xml-object.r script?
Oldes
25-Oct-2010
[147x2]
Is this prefered result?:
>> sort [748x430 68x206 748x194 305x147]
== [305x147 748x194 68x206 748x430]
I take it back.. REBOL cannot have any idea what I want to do, so 
better to use compare function, like:
sort-pairs: func[block-of-pairs][
	sort/compare block-of-pairs func[a b][
		either a/x < b/x [
			1
		][
			either a/x = b/x [
				either a/y < b/y [
					1
				][
					either a/y > b/y [-1][0]
				]
			][ -1 ]
		]
	]
]

sort-pairs [748x430 68x206 748x194 305x147]
;== [748x430 748x194 305x147 68x206]
GrahamC
25-Oct-2010
[149]
What object issues?
james_nak
25-Oct-2010
[150]
XML to objects from SUnday
Steeve
25-Oct-2010
[151]
get-obj-value: func[o [object!] p [path! word!]][attempt[do append 
to-path 'o p]]

Not optimized for speed though...
GrahamC
25-Oct-2010
[152]
hmm... clever