rebol

Error with Test-async-http.r in rebol

青春壹個敷衍的年華 提交于 2019-12-12 03:49:19
问题 I tried http://rebol.wik.is/Protocols/Test-async-http.r do %async-protocol.r do %async-http.r buffer: copy "" content-length: 0 handler: func [port [port!] event [error! word!] ] [ switch event [ connect [print "Connected." false] read [ if port/sub-port/state/inbuffer [ statustxt/text: form length? port/sub-port/state/inbuffer show statustxt if zero? content-length [ either parse/all port/sub-port/state/inbuffer [ thru "content-length: " copy content-length to newline to end ][ if content

Red parse with break

六眼飞鱼酱① 提交于 2019-12-11 08:52:10
问题 my parse code with break doesn't work, I shouldn't get last div block in text: src: { <div class="main"> <div> test </div> <div> test2 </div> <div> test3 </div> </div> <div class="test"> </div> } rules: [ (div-count: 0) some [ to "<div" (div-count: div-count + 1) [if (div-count = 1) mark1:] | thru "</div>" (div-count: div-count - 1) [if (div-count = 0) mark2: break] ] text: copy/part mark1 mark2 ] parse src rules print text Expected result I want is: { <div class="main"> <div> test </div>

red parsing and replacing double % with <> doesn't work

﹥>﹥吖頭↗ 提交于 2019-12-11 08:36:10
问题 I want to transform test: "bla bla %bla bla% bla bla bla bla %bla% bla" into test: "bla bla <bla bla> bla bla bla bla <bla> bla" with this code, it doesn't work in red: rules: [ (toggle: -1) to "%" mark: ( (toggle: 0 - toggle) either (toggle = 1) [change mark {<}][change mark {>}] ) thru "%" | to end ] parse test rules Output is >> test == "bla bla <bla bla% bla bla bla bla %bla% bla" 回答1: Your rules need a little more care, especially when using the keywords 'to and 'thru . The way your rule

What-dir reporting own directory as current directory in Rebol

我的未来我决定 提交于 2019-12-11 05:25:48
问题 I am running Rebol on Debian Stable Linux and I have put rebol executable in /usr/local/bin. Then I have created following script file and also kept it in /usr/local/bin: #! /usr/local/bin/rebol REBOL [] print what-dir quit However, when I run this script from any directory, it only reports "/usr/local/bin/" and not current working directory. I want to get current working directory to perform operations from code. Following code, using Linux shell command pwd (print working directory) also

GUI elements from a function not being displayed in Red language

試著忘記壹切 提交于 2019-12-11 04:32:07
问题 I am using following code to try to get GUI elements from a function: mypanelfn: func[] [ collect[ repeat i 10 [ print append copy "i in loop: " i keep [t: text] keep append copy "message: " i keep [field "entry" button "Click" [t/text: "clicked"] return]]]] view [ do [mypanelfn]] There are no error messages and loop go on all right and a windows is also displayed. But this is only a small empty windows without any text, fields or buttons. What is wrong with this code? Edit: putting probe

How to create Windows executable (.exe) from red lang?

≡放荡痞女 提交于 2019-12-11 04:04:46
问题 I'm building a red lang application. How to create Windows executable (.exe) from red lang??? 回答1: If you have already the red executable, you call from the command line red -c -t Windows yourprogram.red and you will get yourprogram.exe as a Windows program README.md Of course I assume, you have also downloaded all the possibly additionally needed source files from either red-lang/download or github/red/red If you have a recent rebol interpreter, you can compile with do/args %red.r "-t

Cascade in Rebol

被刻印的时光 ゝ 提交于 2019-12-11 02:56:52
问题 In Logo Language, cascade is a procedure to to compose a function with itself several times (it is almost like fold in functional language). Example: add 4 add 4 add 4 5 --> cascade 3 [add 4 ?1] 5 == 17 2^8 --> cascade 8 [?1 * 2] 1 fibonacci 5 --> (cascade 5 [?1 + ?2] 1 [?1] 0) factorial 5 --> (cascade 5 [?1 * ?2] 1 [?2 + 1] 1) General notation for multi-input cascade, in Logo: (cascade how many function1 start1 function2 start2 ...) with: function1 -> ?1 , function2 -> ?2 ... Cascade returns

Trouble with 'export word in module

主宰稳场 提交于 2019-12-11 02:44:49
问题 Let's mod.reb: REBOL[Type: module Name: mod] export: add 1 2 Let's test.reb: import 'mod Running r3 test.reb , got: ** Script error: add has no value ** Where: do module catch case load-module apply for-each case import do either either either --anonymous-- ** Near: ... add 3 2 Same trouble with other funcs instead of 'add. No trouble with other names instead of 'export No trouble inserting a dummy 'export before export: ... (!?) Why this? 来源: https://stackoverflow.com/questions/40284088

How to send an HTTP post with a custom header using REBOL

情到浓时终转凉″ 提交于 2019-12-11 02:44:36
问题 I've been trying to access a site with REBOL using the site's API, but I'm having problems. The API call expects a custom header and a request in XML format. I've been trying with read/custom, but I'm unsure how to include the header, or what format it should take. The default header in system/options/cgi is an object, so I assume it should be an object, but where would you put it? (Adding to system/options/cgi hasn't worked.) I'm guessing the code below is something like what I need... http

Rebol - HTTP response headers

浪子不回头ぞ 提交于 2019-12-11 02:06:21
问题 Where does Rebol (R2) save the HTTP response headers after a call to the read function (which just seems to return the page content)? 回答1: Not sure there is an easy way to get the headers after a straight read. You can get them if you open a port : hp: open http://www.rebol.com probe hp/locals/headers make object! [ Date: "Sat, 07 May 2011 07:08:35 GMT" Server: "Apache" Last-Modified: "Tue, 22/Feb/2011/06:52:26/+GMT" Accept-Ranges: "bytes" Content-Encoding: none Content-Type: "text/html"