Importing functions with do

Soon after starting a project, you will start getting a lot of functions, and you may ask, where should I put their code? You will likely want to have a compact main.red file, which starts your program and can call functions stored in other files.

Let's say one of these files is called useful-functions.red, and contains the functions fact from the previous section and the check function:

;-- see Chapter06/useful-functions.red:check: func [list] [    answer: "safe"    foreach l list [        if find l "--" [answer: "unsafe"]    ]    answer]

 What it does is not that important here. It goes through a list of names, and returns the safe string, but if any name in the list contains  --, check returns the unsafe string.

This is depicted ...

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.