Search code examples
filefwriterebolred-lang

Saving data to file in Red language


I am trying to save data to a file:

a: 0
b: 10
c: 20
d: 30

save %redout.txt [a b c d]

I expected the file to contain the values. However, The file contains:

a b c d

How can I save variable values rather than variable names to the file?


Solution

  • You're saving a block which hasn't been evaluated. Normally you would reduce the block first to get the values before saving them.

    So,

     Save %myfile.txt reduce [a b c d]
    

    And if you want a loadable file with variables, use save/all