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

World: r3wp

[Core] Discuss core issues

Oldes
7-Mar-2011
[1020x8]
No.. it doesn't... it's possible to DO a script which has some sort 
of junk, but not LOAD.
>> load {234523$%$%^& rebol [] print 1}
** Syntax Error: Invalid integer -- 234523$%$%&
** Near: (line 1) 234523$%$%& rebol [] print 1
>> do {234523$%$%^& rebol [] print 1}
** Syntax Error: Invalid integer -- 234523$%$%&
** Near: (line 1) 234523$%$%& rebol [] print 1
>> write/binary %x.r {234523$%$%^& rebol [] print 1}
>> do %x.r
** Syntax Error: Script is missing a REBOL header
** Near: do %x.r
>> write/binary %x.r {234523$%$%^& ^/rebol [] print 1}
>> do %x.r
1
you can have junk at the beggining as long as you have the header 
there (  rebol at the newline start)
rebol with following block.. this does not works:
>> write/binary %x.r {234523$%$%^& ^/rebol none print 1}
>> do %x.r
** Syntax Error: Script is missing a REBOL header
** Near: do %x.r
this works as well:
>> write/binary %x.r {[^/rebol [] print 1] 34532$%*&%$#}
>> do %x.r
1
hmm.. ok... the LOAD is possible as well:
>> load %x.r
== [print 1
]
so you are right
I guess it's how the load/next is implemented... if the header is 
inside a block, it stops there.
Henrik
10-Mar-2011
[1028]
I forget: How do you open an Explorer window from Rebol?
Dockimbel
10-Mar-2011
[1029]
If you want a file requester: request-file, if you just want to spawn 
a new Explorer window for the user, this should work: call "explorer".
Henrik
10-Mar-2011
[1030]
do you know if the call method works under win7?
Dockimbel
10-Mar-2011
[1031]
Works, tested on Win7 with 2.7.6 & 2.7.8.
Henrik
10-Mar-2011
[1032]
thanks very much
Dockimbel
10-Mar-2011
[1033]
You're welcome.
james_nak
11-Mar-2011
[1034]
Is there a trick / limit to just how deep one can create an object 
which itself has nested objects stored in a block? I have this xml 
string that I converted to a block via parse-xml but at about two 
levels in, it remains a block (make object!...)
Sunanda
11-Mar-2011
[1035x2]
Are you missing a reduce?
Or try Gavin's code:
   http://www.rebol.org/view-script.r?script=xml-object.r
Oldes
11-Mar-2011
[1037x2]
I'm using this one http://www.rebol.org/view-script.r?script=xml-parse.r
(not an object)
james_nak
11-Mar-2011
[1039]
Yes, I am using xml-parse and then xml-object. My question is something 
that I have dealing with for a long time actually. So is there a 
limit to how far something is reduced in terms of nesting?
Sunanda
11-Mar-2011
[1040]
Not as far as I know.....I have used some very deeply nested structures.
james_nak
11-Mar-2011
[1041]
And how do you do that? do reduce blk
Sunanda
11-Mar-2011
[1042]
I made a mistake in suggesting that.

I think the code makes blocks rather than objects. You could run 
through the structures changing them to objects.
james_nak
11-Mar-2011
[1043]
Sorry, about these delays. I was on on an online session.
So When I  use parse-xml+  on my xml string, I get the following:
[document [version none
        encoding none
        standalone none
        doctype none
        pubid none
        sysid none
        subset none

    ] [["TTL_Status" none ["^/^-" ["INPUT_TTLS" none ["^/^-^-" ["TTL_IN" 
    ["value" "0"] [{

^-^-^-} ["status" ["value" "1"] none] "^/^-^-"]] "^/^-^-" ["TTL_IN" 
["value" "1"] [{

^-^-^-} ["status" ["value" "1"] none] "^/^-^-"]] "^/^-"]] "^/^-" 
["OUTPUT_TTLS" none ["^/^-^-" ["TTL_OUT" ["value" "0"] [{

^-^-^-} ["status" ["value" "0"] none] "^/^-^-"]] "^/^-"]] "^/"]]]]

I know it's not that readable...

Then I run xml-to-object on that block and get:

o: xml-to-object  blk
where block is the output of parse-xml+ above.

probe o


[document: make object! [TTL_Status: make object! [INPUT_TTLS: make 
object! [TTL_IN: make block! reduce [

                    make object! [status: make object! [value?: "" value: "1"] value: 
                    "0"] make object! [status: make object! [value?: "" value
: "1"] value: "1"]

                ]] OUTPUT_TTLS: make object! [TTL_OUT: make object! [status: make 
                object! [value?: "" value: "0"] value: "0"]]] version: none
        encoding: none
        standalone: none
        doctype: none
        pubid: none
        sysid: none
        subset: none
    ]]


So this is where my ignorance leaves me. How do I make "o" into a 
an object where all the nested objects become real objects and don't 
remain as blocks?
GrahamC
11-Mar-2011
[1044x3]
do o
what you have is rebol source  so you need to execute it
make that

obj: do o
james_nak
11-Mar-2011
[1047x2]
Graham, I'll try that. Thanks.
OK, so I still get an invalid path but looking at the code I can 
see why.
 [TTL_IN: make block! reduce [

                    make object! [status: make object! [value?: "" value: "1"] value: 
                    "0"] make object! [status: make object! [value?: "" value
: "1"] value: "1"]

So it was making a block of objects. I didn't notice that before.

Thanks for your help. I should have looked more carefully before. 
It was always working.
james_nak
12-Mar-2011
[1049]
I think this is a Graham question. I've been trying to communicate 
with this video encoder. It uses .xml and .cgi files to talk to it:
tmp: http-tools http://192.168.1.62/user/GetTTLStatus.xml[]
and this works fine.


The problem is with he .cgi files. They aren't POST files but they 
only return 

 a: http-tools http://192.168.1.62/user/StorageMediaFiles.cgi[] probe 
 a
make object! [
    HTTP-Response: "<?xml version='1.0' encoding='ISO-8859-1' ?>"
    Date: none
    Server: none
    Last-Modified: none
    Accept-Ranges: none
    Content-Encoding: none
    Content-Type: none
    Content-Length: none
    Location: none
    Expires: none
    Referer: none
    Connection: none
    Set-Cookie: none
]
When you place the url in a browser it works as expected. 
Any ideas on how to get this to work?
GrahamC
12-Mar-2011
[1050x2]
maybe there's a redirect or something else going on
What does a simple 'read do ?
james_nak
12-Mar-2011
[1052]
Graham,  I get an error 

Error.  Target url: http://192.168.1.62/user/StorageMediaFiles.cgi
could not be retrieved.  Server response: HTTP/1.1 40.... 
If you know a way to get the full error code, that might help.
Sunanda
12-Mar-2011
[1053]
One idea....Try setting the user-agent to the same as your browser's
   system/schemes/http/user-agent
james_nak
12-Mar-2011
[1054x5]
And you're right, there is probably something else going on. I am 
at least getting part of the message. A successful .xml call looks 
like this:

a: http-tools http://192.168.1.62/user/StorageEventMode.xml[] probe 
a
make object! [
    HTTP-Response: "HTTP/1.1 200 OK"
    Date: none
    Server: "Mango DSP - HTTP Server (v2.34)"
    Last-Modified: none
    Accept-Ranges: none
    Content-Encoding: none
    Content-Type: "text/xml"
    Content-Length: "270"
    Location: none
    Expires: none
    Referer: none
    Connection: none
    Set-Cookie: none
    Cache-Control: "no-store"
    content: {<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="StorageEventMode.xsl"?>
<StorageEventMode>
^-<RecOnNetworkFailure id="RecOnNetworkFailure" checked="true"/>
^-<PreEventBufferTime id="PreEventBufferTime" value="20"/>
</StorageEventMode>
}
]
I'm learning more about what may be happening. According to the docs, 
I may be getting either a 401 or 404 error. More as I figure this 
out.
Problem almost solved. The http-tools'  http-port-private buffer 
is not being read to the end so all along the data was there. Thanks 
Graham and Sunanda...I am learning a lot from you.
So what's happening is that the server is not returning an LF/CR 
to separate the contents from response fields so when it gets to 
 parse-header, that function does not know there is any contents. 
In stead of getthing something like:

HTTP-Response: HTTP/1.1 200 OK
Server: Mango DSP - HTTP Server (v2.34)
Content-Type: 
text/xml
Content-Length: 270
Cache-Control: no-store

<?xml version=
1.0" encoding="ISO-8859-1" ?>"

I am getting:

HTTP-Response: <?xml version='1.0' encoding='ISO-8859-1' ?>
<?xml-stylesheet type='text/xsl' href='StorageMediaFiles.xsl'?>
<StorageMediaFiles>
<MediaFile ..."


Placing a LF between the first and second lines fixes it. I am going 
to kludge it for now since I know what routines work and don't.
Then I am asking the manufacturer to fix that.
Geocaching
16-Mar-2011
[1059x3]
Hello, could anyone explain me why the following code does not work
>> rebcode: copy []
== []
>> append rebcode 'sine/radians
== [sine radians]

while the following code does work
>> rebcode: copy []
== []
>> append/only rebcode 'sine/radians
== [sine/radians]
Also, why the following code does not work:
>> rebcode: copy []
== []
>> append rebcode to-word "sine/radians"
== [sine/radians]
>> append rebcode 0.5
== [sine/radians 0.5]
>> do rebcode
** Script Error: sine/radians has no value
** Near: sine/radians 0.5
while the following one works
>> rebcode: copy []
== []
>> append/only rebcode 'sine/radians
== [sine/radians]
>> append rebcode 0.5
== [sine/radians 0.5]
>> do rebcode
== 0.479425538604203
Rebolek
16-Mar-2011
[1062x3]
'sine/radians is path!. That's why it's added as [sine radians] when 
you don't use append/only.
In case 2, "sine/radians" is not path! (that gets reduced to function 
with refinement) but word! without value. It's possible to get your 
desired behaviour with #2, but it's slow.
You can also do this:

>> rebcode: copy []
== []
>> append/only rebcode make path! [sine radians]
== [sine/radians]
>> append rebcode 0.5
== [sine/radians 0.5]
>> do rebcode
== 0.479425538604203
Geocaching
16-Mar-2011
[1065]
Thanks rebolek... interesting

But what do you mean with "It's possible to get your desired behaviour 
with #2, but it's slow."
Rebolek
16-Mar-2011
[1066]
I mean this:


>> dt [loop 1000 [c: copy [] append/only c 'sine/radians append c 
0.5 do c]]  
== 0:00:00.002512


>> dt [loop 1000 [c: copy [] append/only c load "sine/radians" append 
c 0.5 do c]]
== 0:00:00.035299


In second case, to convert from string! to path!, string must be 
loaded first and as you can see it's about 14x slower in this rough 
test.
Geocaching
16-Mar-2011
[1067]
Understood. Thanks a lot for the time you spent ;)
Rebolek
16-Mar-2011
[1068]
you're welcome :)
Andreas
16-Mar-2011
[1069]
as to why you need append/only: a path! is also a series!, with the 
path componenets being the elements. whitness:

>> type? 'a/b
== path!
>> series? 'a/b
== true