Questions tagged [red]

The Red language is inspired by the interpreted language Rebol, but is compiled and hence has a wider range of application...from device drivers to high-level purposes. It is functional, imperative and symbolic, with prototype-based object support. Like LISP and Rebol, it is homoiconic and thus its own meta-language. It is both statically and JIT-compiled to native code, with strong support for concurrency and parallelism (actors, parallel collections).

Filter by
Sorted by
Tagged with
0 votes
1 answer
70 views

A particular diff

I have 2 files: list-folder1.txt and list-folder2.txt. These files are derived from the ls -1R command run on linux in their respective folders (similar folders consisting of thousands of files and ...
noein's user avatar
  • 411
0 votes
1 answer
79 views

How to integrate Red into Rust?

Does anyone know how to use view from Rust? Do I need to link libRed.dll on Windows? What functions to extern? Must I try to disassemble it? I’m using compiled Red, not interpreted, so libRedRT.lib ...
Miiao's user avatar
  • 801
0 votes
1 answer
72 views

Rebol - How can I append text from a text field to a text list?

I've been exploring the amazing Rebol programming tool. I've run into a problem of trying to append text from a text field into the data of a text-list. My code below adds text to the text-list but ...
awyr_agored's user avatar
0 votes
1 answer
989 views

How to decompress/deflate zlib data [rfc1951]?

I am looking for decompressing data according to the deflate compression mechanism [rfc1951]. The linux command for this mechanism is: zlib-flate -uncompress I try the Red command decompress with ...
user16861490's user avatar
0 votes
1 answer
90 views

behavior of call in Red language

On Red console, I tried the following commands: >> (print 0 call/shell/wait "sleep 5" print 5) I think 0 would be printed first. After 5 seconds delay, 5 would then be printed. In ...
lyl's user avatar
  • 293
1 vote
1 answer
105 views

How to evaluate refinement of a function when calling this function in Red/Rebol

>> f: func [x /a][either a [x + 2] [x + 1]] == func [x /a][either a [x + 2] [x + 1]] >> b: /a == /a >> f/b 1 *** Script Error: f has no refinement called b *** Where: f *** Stack: ...
lyl's user avatar
  • 293
1 vote
1 answer
79 views

How to link other scripts when compiling main program in Red language

I put some functions' defination in a file named "funcs.red", functions in which would be invoked by main program. Here is the example of "funcs.red": Red [] myadd: func [x y] [x + ...
lyl's user avatar
  • 293
0 votes
2 answers
126 views

How to construct a function with a default argument

To make a function with default argument, I tried this: f: function [a b] [either unset? :b [a + 1] [a + b]] f 5 f 3 5 then I receive this message *** Script Error: f is missing its b argument. So, ...
lyl's user avatar
  • 293
2 votes
1 answer
154 views

How to read key from keyboad in red/rebol

We can get input from console by input or ask, which means to press some keys on keyboard and terminate the input by pressing the key "Enter". I'd like to know if there is a way to get a key ...
lyl's user avatar
  • 293
0 votes
2 answers
77 views

Value of local variables in a function seems not be released post function calling in Red/Rebol language

I construct a function named find-all to find all indexes of a given item in a series by "recursive". The first calling of find-all gives the right output. However from the second calling, ...
lyl's user avatar
  • 293
1 vote
1 answer
44 views

Use 'parse' in Red language with number block

I imitate the follow code that comes from Helpin'Red a: "big black cat" parse a [ to "black" insert "FAT "] print a big FAT black cat with mine: b: [1 2 3] parse b [to 2 ...
lyl's user avatar
  • 293
1 vote
1 answer
93 views

In Red language, how to split a string using split, but also keep the delimiters as nessecary

I want to split a string with the split, meanwhile the string contains the string used as delimiter which should not be treated as delimiter. I tried in this way as shown in the following code: >&...
lyl's user avatar
  • 293
0 votes
3 answers
163 views

How to modify each element of a block by "foreach" in red/rebol

I want to modify each element of a block by foreach. I tried like this but failed: >> a: [3 4 5 6] == [3 4 5 6] >> foreach i a [i + 1] == 7 >> a == [3 4 5 6] ;; block a is not ...
lyl's user avatar
  • 293
2 votes
1 answer
141 views

How does functions of Red/Rebol pass parameters, by value or by reference?

I'm puzzled by the result of the following two codes: Code1: >> f: func [x][head insert x 1] == func [x][head insert x 1] >> a: [2 3] == [2 3] >> f a == [1 2 3] >> a == [1 2 3] ...
lyl's user avatar
  • 293
1 vote
1 answer
96 views

How to make anonymous function work in Red/Rebol

In Red/Rebol, parentheses () can be used to evaluate expressions like this: >> (1 + 2 3 + 4) == 7 However, when I use parentheses to evalute an anonymous function, it fails(please see the ...
lyl's user avatar
  • 293
1 vote
1 answer
47 views

How to prevent "collect/keep" function from flatting its result

>> a: [[1 2] "a" a [3 3]] == [[1 2] "a" a [3 3]] >> collect [foreach x a [if block? x [keep x]]] == [1 2 3 3] But what I want is [[1 2] [3 3]]. It seems that collect/...
lyl's user avatar
  • 293
0 votes
1 answer
103 views

Why does loop variable in repeat not work

Loop variable of repeat can be used in its block like this: >> b: func [x] [x + i] == func [x][x + i] >> repeat i 2 [print reduce append copy [b] [3]] 4 5 You can see that the variable &...
lyl's user avatar
  • 293
1 vote
2 answers
124 views

Tracer function written in Rebol

It is possible in Rebol (Red, R3 Ren-c) to write a function similar to TRACE that produces the following result: foo: func [val1 val2 /local temp] [ temp: val1 + 5 val2 + temp ] bar: ...
noein's user avatar
  • 411
2 votes
1 answer
78 views

How do I set an icon to a view in red program?

I want to set an icon for the program main window. I found this page https://www.red-lang.org/2016/03/060-red-gui-system.html which says: Icons and other "resources" are now supported for ...
jakubiszon's user avatar
  • 3,251
1 vote
5 answers
112 views

how to check if char conforms to charset?

tl;dr can't get parse to work with single letter I'm currently learning Red, so I may be missing basic things, but in general I want to check if a password contains uppercase characters; this was my ...
Jakub Koralewski's user avatar
2 votes
2 answers
180 views

Remove button faces

Hi all. I want to know that how can I remove two button face with a button. I tried this: gui: [ en: button "English" remove [en es] es: button "Spanih" remove [en es] ] And than I have to ...
Civan Tunç's user avatar
0 votes
1 answer
98 views

How to pass block with context to routine?

I am continue to learn Red/System. And now I am trying to understand how to pass word with context to function. Here is my code: Red [Note: "compile in release mode (-r flag)"] mycontext: context [ ...
Dmitry Bubnenkov's user avatar
2 votes
1 answer
45 views

How to append data to block from R/S?

I am trying to append data to block from Red/System. Red [] my-red-block: ["some text"] ; some already existen data in block foo: routine [ blk ] [ block/rs-append as red-block! blk as red-...
Dmitry Bubnenkov's user avatar
2 votes
1 answer
130 views

How to pass value from Red/System to Red?

I need to pass the value that I generate in Red/System to Red. I discovered docs but did not find an example of how to use it. Here is my code: Red [] #system [ data!: alias struct! [ ...
Dmitry Bubnenkov's user avatar
0 votes
1 answer
276 views

A 'compiler' for list comprehension in Rebol

I want to compile this list comprehension: >> lc [reduce [x y] | x in [1 2 3] y in [4 5 6]] == [[1 4] [1 5] [1 6] [2 4] [2 5] [2 6] [3 4] [3 5] [3 6]] in: collect [ foreach x [1 2 3] [ ...
noein's user avatar
  • 411
0 votes
2 answers
151 views

What is the best way to save a hash! block in Rebol?

I am using Rebol2 and would like to persist a HASH! block. Currently I am converting it to-string then using save. Is there a better way? For example: r: make hash! ["one" "two"] I want to save ...
Atomica's user avatar
  • 23
2 votes
1 answer
67 views

How can I compile a script that has some dynamic code?

I want to compile this script: Red [File: %b.red] context [ a: 123 hidden: 999 set 'global-exports context [ export-a: a ] ] probe global-exports But I get an error when ...
Maciej Łoziński's user avatar
2 votes
2 answers
338 views

How to do an incremental read of binary files

TL;DR: can I do an incremental read of binary files with Red or Rebol? I would like to use Red to process some large (13MB to 2GB) structured binary files (Kurzweil synthesizer files). I've used ...
aMike's user avatar
  • 852
29 votes
2 answers
31k views

What are terminal and nonterminal symbols?

I am reading Rebol Wikipedia page. "Parse expressions are written in the parse dialect, which, like the do dialect, is an expression-oriented sublanguage of the data exchange dialect. Unlike the ...
Dmitry Bubnenkov's user avatar
1 vote
2 answers
421 views

How to pause program execution for some time?

I'm using "Red Programming Language" version "0.6.4" on Windows and making a command line application. I don't know much Red language and I don't understand many things. I did go over "work in ...
Alex Baban's user avatar
  • 11.3k
1 vote
3 answers
314 views

How to get a formatted date and time string from `now`?

I'm using "Red Programming Language" version "0.6.4" on Windows and making a command line application. I don't know much Red language and I don't understand many things. I did go over "work in ...
Alex Baban's user avatar
  • 11.3k
1 vote
1 answer
219 views

Why POST in red language change the first character of parameters to upper-case automaticlly?

For the following simple code, Red [] #include %tools.red url: to url! rejoin ["http://somesite.com:7466/japi"] response: write url [ post [ Content-Type: "application/json" ...
Topget's user avatar
  • 113
4 votes
3 answers
220 views

Differences between Red's 5 function types, and why does it distinguish them?

In Red, there are functions of datatypes function!, op!, native!, routine! and action!. What are the differences between them? As far as I know function! is used for user-defined functions and op! for ...
nickkoro's user avatar
  • 374
0 votes
1 answer
90 views

Red to dotnet or java android: .Net -> Red (Not Implemented)

On https://github.com/red/red/tree/master/bridges it says not implemented, will it be ?
user310291's user avatar
  • 37.1k
1 vote
1 answer
97 views

Rebol PARSE rule to match thru first occurrence of at least 2 spaces

rule: [while [not ["--"] skip] some "-"] parse "a-bc----d" [rule ??] prints ??: "d" But I need a more efficient rule (e.g. using to #"-")... EDIT: t: copy "" append/dup t "." 10000 append t "-..--...
giuliolunati's user avatar
3 votes
2 answers
97 views

rebol / red parse with [to end] rule

I'm trying to understand parse from the ground up so don't tell me to use split in this case. sentence: "This is a sentence" parse sentence [ any [ [any space] copy text [to space | to ...
user310291's user avatar
  • 37.1k
0 votes
1 answer
118 views

In Red, how do I search through a block for a string matching a pattern?

Given: player-wins: [ "rock breaks scissors" "paper covers rock" "scissors cut paper" ] I want a function which accepts two strings, each representing any of rock, paper or scissors ...
Terrence Brannon's user avatar
0 votes
4 answers
120 views

How to increment element of block after found element?

Given player-choices: ["rock" 0 "paper" 0 "scissors" 0] How could I increment the value after "paper" in this block by searching for "paper"?
Terrence Brannon's user avatar
0 votes
4 answers
151 views

How to find the first element of a block of strings whose first character matches an input character?

Given weapons: ["rock" "scissors" "paper"] If I did player-choice: ask "(r)ock, (p)aper, (s)cissors or (q)uit? " how could i look for the character entered by the user in the block with word weapons ...
Terrence Brannon's user avatar
0 votes
2 answers
63 views

How did `find` actually locate a character in a string, when it was passed a string, not a character?

I was surprised to note that find "rspq" "q" actually found q in the series. The reason it surprised me is that the string "rpsq" is a series of characters and I expected to have to specify "q" as a ...
Terrence Brannon's user avatar
1 vote
2 answers
136 views

How to create a series from 1000 to 9999 using Red language

Using Red language, I want to choose a random number from 1000 to 9999. Having looked at the docs for random I would like for random to choose a number from a series ranging from 1000 to 9999. I ...
Terrence Brannon's user avatar
1 vote
1 answer
357 views

How to connect to sqlite3 with red

I have tried loading two sqlite libraries mentioned on the red website, however they both are rebol based and give "invalid issue" errors such as: *** Syntax Error: invalid issue! at "^-^-^-#[...
rahul's user avatar
  • 598
0 votes
1 answer
81 views

How to convert a string to Date in red

If I accept a date from a user using ask and then wish to use it as a Date by using to-date, I get an error. >> to-date "31-Dec-2019" *** Script Error: cannot MAKE/TO date! from: "31-Dec-2019" *...
rahul's user avatar
  • 598
2 votes
0 answers
121 views

Segmentation fault with Gtk console on 64-bit system

I've compiled a Red console with Gtk3 support. When I run View tests, such as included in repo tests/react-test.red, i get an error: $ ./console tests/react-test.red *** Runtime Error 32: ...
Maciej Łoziński's user avatar
1 vote
6 answers
193 views

Red: any alternative to using do for adding dynamic keys to a block

Is there an alternative syntax for : a: [ b: [ 1 2 ] ] append (do "a/b") 3 == [ b: [ 1 2 ] ] I don't feel this as very elegant using do (it ressembles too much eval in ...
user310291's user avatar
  • 37.1k
-3 votes
1 answer
68 views

red: path o/a is not valid for integer! type

This code works: o: context [ a: 1 ] o/a This one doesn't: o: context [ a: 1 return a ] o o/a * Script Error: path o/a is not valid for integer! type * Where: catch ...
user310291's user avatar
  • 37.1k
1 vote
1 answer
103 views

How to append a new data block with new-line in red?

I tried: data: [a b c] new-line tail data true append data [d e f] I get [a b c d e f] not what I expect: [a b c d e f]
user310291's user avatar
  • 37.1k
3 votes
1 answer
344 views

How do I get input from the console in Red language

I'm writing a console program (target MSDOS) in Red language and I need to ask the user to enter a character or a string, then to press Enter. I can't seem to find how to do it, I've read the docs ...
Alex Baban's user avatar
  • 11.3k
1 vote
2 answers
262 views

How can I read values from a configuration file (text)?

I need to read values (text) from a configuration file named .env and assign them to variables so I can use them later in my program. The .env file contains name/value pairs and looks something like ...
Alex Baban's user avatar
  • 11.3k
2 votes
1 answer
125 views

How to use a variable in headers when making a POST request in Red

I'm trying to make a POST request using Red language. I have to pass a header with authorization, and I'm computing the value for the authorization string before making the request and saving it in a ...
Alex Baban's user avatar
  • 11.3k

1
2 3 4 5