I know how to accomplish the final result of what I am trying to, but I am wondering if there is a better way. I plan to have a data file that will be one line of text containing values understandable to REBOL. I plan to bring that file into memory with the 'load' function which will result in a block of values. I know that I can modify the values by referring to BLOCK-NAME/1, BLOCK-NAME/2, etc., and then can rewrite the block to the data file with the 'save' function. BUT, I an wondering if there is a better way, specifically, by referring to BLOCK-NAME/1, BLOCK-NAME/2, etc. with more meaningful names to indicate what those values really are. The demo script below shows my attempt, which does not work. I am wondering if this can be done at all.
Thank you.
R E B O L [
]
;; -- This file contains one line of text, containing:
;; -- 'john' 'quincy' 'adams'
DATAFILE-NAME: %set-test.txt
;; -- We want to load the data into memory with one line of code.
DATAFILE: load DATAFILE-NAME
;; -- We want these three words to refer to the three values in the file.
DATANAMES: [FIRSTNAME MIDDLENAME LASTNAME]
;; -- Set the above words to refer to the three values in the file.
set DATANAMES DATAFILE
;; -- Test the 'set' to see that it worked.
print 'Starting values:'
print [DATAFILE/1 ' = ' FIRSTNAME]
print [DATAFILE/2 ' = ' MIDDLENAME]
print [DATAFILE/3 ' = ' LASTNAME]
;; -- Try to change the middle name by referring to the word.
;MIDDLENAME: 'steven'
MIDDLENAME: copy 'steven'
;; -- Test to show that it did not do as we hoped.
print [DATAFILE/2 ' = ' MIDDLENAME]
;; -- We hope to be able to save the new values with one line of code.
;; -- We would like the saved file to contain:
;; -- 'john' 'steven' 'adams'
save DATAFILE-NAME DATAFILE
print 'Check saved data.'
print 'The data file remains unchanged.'
halt