rebol

How to capture words bound in outer context when creating new context?

孤人 提交于 2019-12-11 01:49:29
问题 Let us say I have a situation like this: ;; Capture whatever the print word pointed to into a variable outer-print: :print foo: context [ ;; within foo, override print and implement in terms of outer-print print: func [value] [ outer-print "About to print" outer-print value outer-print "Done printing" ] ] I can do this, or if I have more than one thing I want from the outer context I could capture it explicitly: ;; Capture current context into something called outer outer: self foo: context [

How to parse a functions argument block?

余生颓废 提交于 2019-12-11 01:19:36
问题 I'd like to reorganise the arguments block in a given Rebol function to provide a more comprehensible understanding of the arguments required by the function. The arguments block in a Rebol function is a great example of the malleable data structures in Rebol: adjoin: func [ "Adjoins" series [series!] "Series to adjoin" joinee /local other ][...] But I need something more predictable to make sense of this metadata. How would I get it to a more compliant format? An example: [ ; should include

Rebol: problem with not enough memory

社会主义新天地 提交于 2019-12-10 22:12:14
问题 I have run this program below with a symbol_list of a few hundreds symbol and at some moment it says not enough memory whereas I do reuse the same variable why ? base-url: http://www.google.com/finance/historical download-directory: "askpoweruser/stock-download/google/files/" column-header: "Time;Open;High;Low;Close;Volume" #debug: true symbol_list: parse/all {GOOG AAPL MSFT INDEXDJX:.DJI} " " ans: ask {symbols by default "GOOG AAPL MSFT INDEXDJX:.DJI": } if (ans <> "") [symbol_list: parse

In Rebol, what is the idiomatic way to read a text file line by line?

我与影子孤独终老i 提交于 2019-12-10 17:24:06
问题 For the purpose of reading a text file line by line, without loading the entire file into memory, what is the common way to do this in Rebol? I am doing the following, but I think (correct me if I'm wrong) that it loads the whole file into memory first: foreach line read/lines %file.txt [ print line ] 回答1: At least with Rebol2 read/lines/direct/part %file.txt 1 should come near to what you want but if you want all lines one line after the other, it should be like f: open/lines/direct %test

Rebol GUI on Android Displays Too Small

时光怂恿深爱的人放手 提交于 2019-12-10 10:46:13
问题 So I've discovered Rebol, and am thrilled that it runs on Android. When I create a GUI, though, the GUI first pops up with the top left corner in the center of the screen, and I cannot move or resize the window. If I rotate my phone to a horizontal display, the window resizes itself to the screen properly. Then I rotate my phone to a vertical display, and the window fills the screen properly. But everything on the window is minuscule--almost too small to interact with via finger taps. I haven

Using TAB to move between fields in Red language

我的未来我决定 提交于 2019-12-09 04:36:28
I have following simple code: Red [] view [ text "Value of x:" f1: field "" return text "Value of y:" f2: field "" return text "Read Sum:" tt: text "" return button "Calculate" [ tt/text: to-string ((to-integer f1/text) + (to-integer f2/text)) ] button "Quit" [quit] ] How can I add code so that one can move between different fields using TAB key? Apparently, this works in Rebol ( http://www.rebol.com/how-to/fields.html ) but is not working here. according gitter archive handle-key: function [e prev-fld next-fld][ k: e/key if k = tab [ either e/shift? [win/selected: prev-fld][win/selected: next

If…else if…else in REBOL

我的未来我决定 提交于 2019-12-08 17:43:29
问题 I've noticed that REBOL doesn't have a built in if...elsif...else syntax, like this one: theVar: 60 {This won't work} if theVar > 60 [ print "Greater than 60!" ] elsif theVar == 3 [ print "It's 3!" ] elsif theVar < 3 [ print "It's less than 3!" ] else [ print "It's something else!" ] I have found a workaround, but it's extremely verbose: theVar: 60 either theVar > 60 [ print "Greater than 60!" ][ either theVar == 3 [ print "It's 3!" ][ either theVar < 3 [ print "It's less than 3!" ][ print

How to bind to foreach context?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 12:21:07
问题 Currently I have this snippet of code: Blocks: ["F4369RO771" "282273" "5" "146" "126" "6-Nov-2009" "8-Jan-2010" "7-Jun-2010" "8" "M9881KI923" "399727" "2" "359" "443" "5-Aug-2010" "23-Feb-2010" "6-Nov-2009" "4" ] save-blocks: func[file /local f out][ foreach [field1 field2 field3 field4 field5 field6 field7 field8 field9] blocks [ out: copy "" repeat n 9 [ part: get bind to-word rejoin ["field" n] 'field1 out: rejoin [out part ";"] ] remove back tail out write/lines/append f out ] It's not

I need to generate 50 Millions Rows csv file with random data: how to optimize this program?

家住魔仙堡 提交于 2019-12-08 10:23:27
问题 The program below can generate random data according to some specs (example here is for 2 columns) It works with a few hundred of thousand lines on my PC (should depend on RAM). I need to scale to dozen of millions row. How can I optimize the program to write directly to disk ? Subsidiarily how can I "cache" the parsing rule execution as it is always the same pattern repeated 50 Millions times ? Note: to use the program below, just type generate-blocks and save-blocks output will be db.txt

Using TAB to move between fields in Red language

大兔子大兔子 提交于 2019-12-08 04:57:31
问题 I have following simple code: Red [] view [ text "Value of x:" f1: field "" return text "Value of y:" f2: field "" return text "Read Sum:" tt: text "" return button "Calculate" [ tt/text: to-string ((to-integer f1/text) + (to-integer f2/text)) ] button "Quit" [quit] ] How can I add code so that one can move between different fields using TAB key? Apparently, this works in Rebol ( http://www.rebol.com/how-to/fields.html ) but is not working here. 回答1: according gitter archive handle-key: