rebol

Avoiding recursion when reading/writing a port synchronously?

好久不见. 提交于 2019-12-03 00:52:19
All port operations in Rebol 3 are asynchronous. The only way I can find to do synchronous communication is calling wait . But the problem with calling wait in this case is that it will check events for all open ports (even if they are not in the port block passed to wait). Then they call their responding event handlers, but a read/write could be done in one of those event handlers. That could result in recursive calls to "wait". How do I get around this? Why don´t you create a kind of "Buffer" function to receive all messages from assyncronous entries and process them as FIFO (first-in, first

Making GUI objects in Red language

蓝咒 提交于 2019-12-02 17:45:55
问题 I have following simple code for a small panel: view [ t: text "label" f: field button "Click here" [t/text: f/text] ] But I have to make 2 of them and put them on one window. I want to create single object class and make 2 objects out of it. I see that objects can be created as follows: obj: object [ view [ t: text "label" f: field button "Click here" [t/text: f/text] ] ] view [ obj obj ] But I get following error: *** Script Error: VID - invalid syntax at: [obj obj] *** Where: do *** Stack:

Rebol / Red Parse html rules returns true but nothing is inserted

£可爱£侵袭症+ 提交于 2019-12-02 16:23:30
问题 I have a parse rules that returns true but it doesn't insert my text as expected : the html is unchanged whereas it should have inserted at the end of the main closing div. I tried to use a counter like How to parse inside HTML tags with REBOL? Update: I also don't know how to break out of the parsing as soon as counter = 0 so as not to insert text before last closing div after main. content: {<div class="main"> <h1> Big TITLE </h1> <div> <section> <p>a paragraph</p> </section> <section> <p>a

Rebol / Red Parse html rules returns true but nothing is inserted

十年热恋 提交于 2019-12-02 08:25:30
I have a parse rules that returns true but it doesn't insert my text as expected : the html is unchanged whereas it should have inserted at the end of the main closing div. I tried to use a counter like How to parse inside HTML tags with REBOL? Update: I also don't know how to break out of the parsing as soon as counter = 0 so as not to insert text before last closing div after main. content: {<div class="main"> <h1> Big TITLE </h1> <div> <section> <p>a paragraph</p> </section> <section> <p>a paragraph</p> </section> <section> <p>a paragraph</p> </section> </div> <div> <p>Blah Blah</p> </div>

Change path or refinement

混江龙づ霸主 提交于 2019-12-02 06:40:36
问题 I want to change the a/b inside a block to a/c (or possibly even a ) The normal way I'd do this is with change : test: [a/b] change test/1 'c but it only changes the first part, i.e. a to c : >> test == [c/b] Can't access the path with test/2 either: >> reduce [test/1 test/2] == [a/b none] 回答1: There are 2 things to note here: First, path! is a series, so in this case, a nested series. Have to actually access the second element inside the first element: >> test: [a/b] test/1/2 == b Secondly,

Change path or refinement

血红的双手。 提交于 2019-12-02 06:17:43
I want to change the a/b inside a block to a/c (or possibly even a ) The normal way I'd do this is with change : test: [a/b] change test/1 'c but it only changes the first part, i.e. a to c : >> test == [c/b] Can't access the path with test/2 either: >> reduce [test/1 test/2] == [a/b none] There are 2 things to note here: First, path! is a series, so in this case, a nested series. Have to actually access the second element inside the first element: >> test: [a/b] test/1/2 == b Secondly, use the property of series that make them behave like pointers and access the next element, instead of

Use strings to create words and paths in Red language

99封情书 提交于 2019-12-02 00:30:25
I have strings in a namelist , that correspond to variables as well as field names in the application. The function should read strings from namelist, add an 'f' to get field_names, and then put variable values in corresponding fields. I tried following code, that does not give any error, but also does not work: namelist: ["var1" "var2"] var1: 5 var2: 10 process: [ repeat i length? namelist [ (to-set-path compose rejoin [namelist/:i "f/text"] (to-word namelist/:i)) ] ] lay: layout [ text "Values to appear here: " var1f: field "a" var2f: field "b" button "Click" [do process] ] view lay As a

Extending Build-markup with repeat refinement

醉酒当歌 提交于 2019-12-01 14:03:02
I tried to add a repeat refinement to build-markup function using the previous answer: How to bind to foreach context? build-markup: func [ {Return markup text replacing <%tags%> with their evaluated results.} content [string! file! url!] /repeat block-fields block-values /quiet "Do not show errors in the output." /local out eval value ][ either not repeat [ content: either string? content [copy content] [read content] out: make string! 126 eval: func [val /local tmp] [ either error? set/any 'tmp try [do val] [ if not quiet [ tmp: disarm :tmp append out reform ["***ERROR" tmp/id "in:" val] ] ]

Using PARSE on a PORT! value

喜欢而已 提交于 2019-12-01 09:34:06
I tried using PARSE on a PORT! and it does not work: >> parse open %test-data.r [to end] ** Script error: parse does not allow port! for its input argument Of course, it works if you read the data in: >> parse read open %test-data.r [to end] == true ...but it seems it would be useful to be able to use PARSE on large files without first loading them into memory. Is there a reason why PARSE couldn't work on a PORT! ... or is it merely not implemented yet? the easy answer is no we can't... The way parse works, it may need to roll-back to a prior part of the input string, which might in fact be

call curl from rebol or red doesn't work

两盒软妹~` 提交于 2019-12-01 09:16:27
On dos cmd this works: curl.exe -L https://dl.uxnr.de/build/curl/curl_winssl_msys2_mingw64_stc/curl-7.53.1/curl-7.53.1.zip > curl.zip On red or rebol, following suggestion Cannot read a binary file with red from http , I tried code below but it doesn't work why ? call {curl.exe -L https://dl.uxnr.de/build/curl/curl_winssl_msys2_mingw64_stc/curl-7.53.1/curl-7.53.1.zip > curl.zip} I also tried call/wait, it doesn't work either. Rebol2: call/output {curl.exe -L https://www.example.com} data: make string! estimated-big-enough-number Rebol3 (Ren/C branch): call/shell/output {curl -L https://www