Loading and saving files

Red also has the save and load words, that can be used interchangeably with write and read. However, save and load are generally used to store more complex data structures, and in particular to store and load Red code. But we already know that in Red, code can be treated as data.

To see for yourself that save and load can be used for data, answer question 4 in the Questions section.

The save word can also be used to write data into a string or binary value.

In particular, if you have a file with data items separated by a space, load will transform that into a series with the items. Suppose we have a names file with the following contents:

"John" "Dave" "Jane" "Bob" "Sue" "Sarah" "Mikhail" "Rudolf" "Nenad"

If we use  ...

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.