Question

I am just getting started with Red and I need help to get the cURL binding working.

The cURL link from the main red-lang site takes you here

http://red.esperconsultancy.nl/Red-cURL/dir?ci=tip

But there is only a small example using Red/System hence I am not sure how to load the binding in Red directly.

I need to get this working on Mac, Linux and maybe Windows so I would appreciate any pointers to differences between these platforms.

Was it helpful?

Solution

A few things to address:

  1. Next, there are some dependencies between bindings. I am maintaining a github clone if you don't want to use the script download.r in the Red-test files with Fossil. The cURL library explicitly depends on the C-library binding. I didn't look, but like depends on the Common binding at a lower level.

  2. Because of the lack of url! type in Red at the moment, you pass the function read-url a string! or a c-string! more specifically.

  3. With Red/System bindings used in Red, the ideal situation is to have a wrapper that abstracts the lower level code. You can see this on TryRebol with running read "http://www.google.com". Although this console build does not seem to use cURL binding for that implementation.

  4. In order to use a Red/System binding in Red, you need to use the #system-global directive. Here is a simple script that grabs the data from a website:

    Red[]
    
    #system-global [
        #include %../cURL.reds
        with curl [
            print read-url "http://www.red-lang.org"
        ]
    ]
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top