Menu
  • HOME
  • TAGS

What is causing a “word not bound to context” error in this script?

rebol,rebol3,r3-gui

The problem is arising because the anonymous function that is being created by the parse-layout function should be a closure, and it isn't. See the diff at https://gist.github.com/earl/a009454787d9fe4cfaca which fixes the problem.

How can I turn on a word's new-line state in Rebol?

rebol,rebol3

Seemingly the new-line state is assigned to the word based on whether the assigned value has a preceding new-line at the time of assignment (I'll ruminate on the correctness of that statement for a while). This function reassigns the same value (should retain context) to the word with a new...

How do you define your own datatype in Rebol?

rebol

Often suggested, as of today not implemented available only as an experimental patch by Giulio. Any useful custom datatype proposals usually come along with the desire to hook them in so they could effectively "overload" things like + or append. There is an internal layer of abstraction called an ACTION!...

How to extend object by adding a function, and then access original object using self?

rebol,rebol3

Given the workings of "definitional scoping"...your routine defined as does [print self/key] did binding into the enclosing context. That context could be a module or some context we can't see here. But let's introduce a manual context just to show what I mean: context [ key: "OUTER CONTEXT KEY" email-service!:...

Add to map inside of parse dialect

rebol,rebol3,red

You need to reduce the words quarto_hash and quarto_url if not old [append checksums reduce [quarto_hash quarto_url ]] There is also no need to extract the words of the map, you should be faster with a select direct on the map I would use if not select checksums quarto_hash [...

Object vs Block

rebol,rebol3

Why not dialect? [h1 10x30 "Hello World!" font arial] Internally I would store it as an object!, because it provides you with an easier manipulation....

copy/part with pair in REBOL 3

rebol,rebol3

The /part pair! refinement works with images. The pair relates to the x/y coordinates as in >> img: load %image.png == make image! [519x391 #{ 1D2F9F1D2F9F1C2E9E1C2E9E1B2D9D1B2D9D1B2D9D1B2D9D1D2F9F1C2E9E 1A2C9C192B9B192B9B1A2C9C1B2D9D1C2E9E1D2EA01... >> copy/part img 2x2 == make image! [2x2 #{ 1D2F9F1D2F9F1D2F9F1D2F9F }] REBOL/View Image Datatype And here an example how /part series! is working...

Access word value inside object

object,scope,rebol,rebol3,red

When Rebol creates an object, it collects the (set-)words from the spec first and uses them to create the new object. The words of the new object are initially assigned to none. The spec is then bound to the new object and evaluated. In your first example, you haven't included...

type of literal words

rebol,red

A LIT-WORD! if seen in a "live" context by the evaluator resolves to the word itself. It can be used to suppress evaluation simply with a single token when you want to pass a WORD! value to a function. (Of course, in your own dialects when you are playing the...

If…else if…else in REBOL

switch-statement,rebol,rebol3

The construct you would be looking for would be CASE. It takes a series of conditions and code blocks to evaluate, evaluating the blocks only if the condition is true and stopping after the first true condition is met. theVar: 60 case [ theVar > 60 [ print "Greater than...

What's the most efficient way to decode a UTF16 binary?

unicode,utf-16,rebol,rebol3

OK, there doesn't seem to be an easy way to do it. So I just added two codecs UTF-16LE/BE for this purpose. See this commit: https://github.com/zsx/r3/commit/630945070eaa4ae4310f53d9dbf34c30db712a21 With this change, you can do: >> b: encode 'utf-16le "hello" == #{680065006C006C006F00} >> s: decode 'utf-16le b == "hello" >> b: encode 'utf-16be...

Partial read from urls with READ/PART or READ/SEEK

rebol,rebol3

You can see from the source https://github.com/rebol/rebol/blob/master/src/mezz/prot-http.r#L424 that the read actor does not have any refinements defined. This doesn't mean they can't be defined but at present no decision has been made on whether it should be done by using refinements, or by using a query dialect. You can see...

save to disk in append mode

rebol,rebol3,red

save is a mezzanine function, that is basically write mold. So it's possible to mimic the save function using write or it's possible to update save function to support /append refinement.

Text and caret in VID or R3-Gui

rebol,rebol3,r3-gui

As you want the conversion on the fly, you can either modify R3-GUI before loading. So load r3-gui.r3 down to your local directory. Then you add the line if key == #"w" [key: #"z"] to the function do-text-key, so it looks like do-text-key: funct [ "Process text face keyboard events."...

Write a block array of data to a file

rebol,rebol3

Rebol keeps newlines as they are. But after reading with read/lines you just get a block of items without the newlines. If you want a block of items written as lines separated by newlines, you should write them again with the refinement write/lines and Rebol adds the newlines again. myArray:...

file stop read when line reached

rebol

You have always to read the file before you can search in the content of the file. Maybe you are looking for something like clines: read/lines %myfile found: false foreach line clines [ if any [ found found: find line "start" ] [ print line ] ] an other way...

load a map of hash - object key pair

rebol,rebol3,red

SAVE uses an imperfect but more readable format. Use SAVE/ALL to preserve all values exactly as they should be (SAVE/ALL uses so call serialization format in form of #[datatype! value]). Also, just use LOAD and not DO LOAD to get the data back. DO is not required in this case...

Difference between BREAK and REJECT in PARSE

parsing,rebol,rebol3,red

The truth value produced by break depends on whether the minimum number of iterations in an iterative rule have been reached or not. >> parse "aaabbb" [ some [ "a" break ] to end] == true Here we have matched "a" at least once, and then broken out of the...

How to pass functions as parameters in REBOL

rebol

You have discovered that by the nature of the system, when the interpreter comes across a WORD! symbol type which has been bound to a function, it will invoke the function by default. The default interpreter seeing a GET-WORD! symbol type, on the other hand, suppresses invocation and just returns...

Is it possible to implement DO + function in pure REBOL?

rebol

The cause of the behavior you are seeing is specifically this line of code for the Rebol native DO. /*********************************************************************** ** */ REBNATIVE(do) /* ***********************************************************************/ { REBVAL *value = D_ARG(1); switch (VAL_TYPE(value)) { /* ... */ case REB_NATIVE: case REB_ACTION: case REB_COMMAND: case REB_REBCODE: case REB_OP: case REB_CLOSURE: case REB_FUNCTION:...

How to break out of a subrule once a certain part of the rule is met?

midi,rebol,rebol3,firmata

You'll need to break the loop when it hits sysex-end one way or another. You either match sysex-end each time around the loop and break when it hits, or you only match against everything which is not a sysex-end. The first option obviously brings sysex-end into the subrule, but it...

How do you set initial focus in a layout?

rebol,rebol3,r3-gui

The correct trigger to use is the 'enter trigger when [enter] on-action [focus f] ...

Enumerating the properties of an object

rebol,rebol2

I am used to use help on objects as in >> help system SYSTEM is an object of value: version tuple! 2.7.8.3.1 build date! 1-Jan-2011/16:39:07-8:00 product word! View core tuple! 2.7.8 components block! length: 60 words object! [unset! error! datatype! context! native! action! ... license string! {REBOL End User License...

VID layout pane supporting multiple face creations [rebol2]

rebol,rebol2

As is already pointed out the problem is that a is reused, not b! the layout function uses a field called init for handling things like this. As I understand it init is first bound to the face and then called with do after the face itself is instantiated (at...

Print binary data to stdout using Rebol

rebol,rebol3,rebol2

In Rebol 2 you can use write-io for unadulterated writing to ports like STDOUT. So your example would look like this: Rebol [] for i 0 255 1 [ write-io system/ports/output to-string to char! i 1 ] Rebol 3 doesn't have write-io and instead uses write so in theory your...

Is there a better way to restyle REBOL VID modal dialogs?

rebol,rebol2

Regrettably, as far as I know there isn't. I've had this problem myself in the past. The only way to do it, is as you said. Of course, that's fairly trivial since you can simply do: source request, copy it and make your changes. Request and the other modals are...

strange “word has no context” error in rebol program

bind,rebol

I don't know how you defined column and a because when I try it from console, it works: >> column: [Person 2 Date 3 Quantity 4 Size 5 ProductType 6 LineItem 7 Deliver 8 FillStatus 9 Note 10 Time 11] == [Person 2 Date 3 Quantity 4 Size 5 ProductType...

What's the purpose of #[datatype] constructor in Rebol

rebol,rebol3

This syntactic structure is called "construction syntax" (also see CureCode issue #1955). Its raison d'être is to allow literal forms for values which could not otherwise be directly represented. There are two main classes of situations that require construction syntax. Values which (except for construction syntax) have no separate lexical...

How to express branch in Rebol PARSE dialect?

parsing,rebol,rebol3

I much favour (where possible) building up a set of grammar rules with positive terms to match target input—I find it's more literate, precise, flexible and easier to debug. In your snippet above, we can identify five core components: space: use [space][ space: charset "^-^/ " [some space] ] word:...