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

World: r3wp

[Core] Discuss core issues

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
[1069x4]
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
>> first 'a/b
== a
>> second 'a/b
== b
Which is why just APPENDing a path! to a block! separately appends 
each component of the path, just as for other series:

>> append t: copy [1 2] [3 4]
== [1 2 3 4]
>> append t: copy [1 2] 'a/b
== [1 2 a b]
If you want to append a series as a whole to another, you use the 
/only refinement:

>> append/only t: copy [1 2] [3 4]
== [1 2 [3 4]]
>> append/only t: copy [1 2] 'a/b  
== [1 2 a/b]
Rebolek
16-Mar-2011
[1073]
I think that the help for append should be corrected from:


/only -- Only insert a block as a single value (not the contents 
of the block)

to


/only -- Only insert series as a single value (not the contents of 
series)
Andreas
16-Mar-2011
[1074]
Absolutely!
Gregg
16-Mar-2011
[1075]
Not sure on that Bolek. It might then be confusing in the other direction, 
where appending a string without /only could be expected to append 
the individual chars. Since path! is any-block! the existing help 
is OK IMO.
ChristianE
16-Mar-2011
[1076]
Seems like it's neither block!s alone nor all series! values, seems 
like it's any-block! values which append/only inserts as a single 
value only.
Gregg
16-Mar-2011
[1077]
Yes. I guess it could say "Appends any block value as a single value" 
to be a little clearer.
ChristianE
16-Mar-2011
[1078]
/only -- Appends any block value as a single value only (not the 
contents)


Is that good enough english to probably suggest it for R3 in curecode 
and R2 rambo?
Gregg
17-Mar-2011
[1079]
The English is fine, but is it really more meaningful?
Endo
17-Mar-2011
[1080]
Why FORMing a datatype! removes the ! char? We cannot get it back 
to datatype without adding a ! to the end:
to-datatype to-word form integer! ;not working
to-datatype to-word join form integer! "!" ;ok


is this a bug, if it is by-desing what is the reason to remove "!"?
Rebolek
17-Mar-2011
[1081]
I think it's by design. FORM makes values "more readable". You'd 
better use MOLD for what you need.
Endo
17-Mar-2011
[1082]
yes MOLD is better use, thank you. I just curious about why FORM 
removes ! char. I think it prevents to manually remove ! char in 
this kind of situations:
a: 5 reform [a "is an" type? a]
>> 5 is an integer
Rebolek
17-Mar-2011
[1083]
Yes, I think this is exact user-case for FORM.
Geocaching
17-Mar-2011
[1084]
Hello


Just a basic question: when creating or resetting a string! or a 
block!, should we do
a: ""
b: []
or is better to do
a: copy ""
b: copy []

I tend to do the second way...

Does it make a difference? If yes, which way is better.

Thanks
Ladislav
17-Mar-2011
[1085x3]
This is the difference:

>> my-code-a: [a: "" append a #"x"]
== [a: "" append a #"x"]

>> do my-code-a
== "x"

>> my-code-a
== [a: "x" append a #"x"]

>> my-code-b: [b: copy "" append b #"x"]
== [b: copy "" append b #"x"]

>> do my-code-b
== "x"

>> my-code-b
== [b: copy "" append b #"x"]
Which one is better may depend on the application
usually, though, the latter is safer
Geocaching
17-Mar-2011
[1088x2]
Thanks ladislav
The bahaviour of my-code-a is confusing... What could be the point 
to do a: "" then?
Ladislav
17-Mar-2011
[1090]
E.g. if you want such a behaviour, i.e. if the effect is desired.
Geocaching
17-Mar-2011
[1091]
the statement a: "" is useless... You could obtain the same behaviour 
without repeating a: ""
Ladislav
17-Mar-2011
[1092]
Certainly, I prefer the latter, like you do.
Geocaching
17-Mar-2011
[1093]
???
>>  my-code-a: [a: [] append a 'x]
== [a: [] append a 'x]
>> do my-code-a
== [x]
>> do my-code-a
== [x x]
>> a: []
== []
>> a
== []
>> head a
== []
>> do my-code-a
== [x x x]
>> a
== [x x x]


what is the logic behind this? How could a be empty after a: [] and 
be filled will three 'x after just one call to do my-code-a
Ladislav
17-Mar-2011
[1094]
:-D you need to consult the MY-CODE-A block contents
Rebolek
17-Mar-2011
[1095]
Because oit's different A
Ladislav
17-Mar-2011
[1096]
(or, be careful, and use the copy [...] construct)
Geocaching
17-Mar-2011
[1097]
Rebolek: both calls to 'a are in the same context (root context) 
How could we have two different 'a in the same context?
Ladislav
17-Mar-2011
[1098x2]
The variable is not different, Francois, but the blocks are
it's like

a: []
a: [1 2 3]


how come? that after no insert at all I get three elements in an 
(originally empty block? ;-)
Geocaching
17-Mar-2011
[1100]
Sorry... i do not understand...
 
>> a
== []

>> a
== [x x x]
Ladislav
17-Mar-2011
[1101]
>> my-code-a: [a: [] append a 'x]
== [a: [] append a 'x]
>> do my-code-a
== [x]
>> do my-code-a
== [x x]
>> a: []
== []
>> my-code-a
== [a: [x x] append a 'x]
>> do my-code-a
== [x x x]
>> a
== [x x x]