Home > Storing Data > Store Simple Values in Files

Store Simple Values in Files

This example shows how to save data out to a file and loading it back again.

For simple single values, you just save them out to a file.

To store an integer:

num: 123
save %num.r num

To store a string:

name: "Tom Smith"
save %name.r name

You can use any suffix for the file. We use .r here because the data is in REBOL format, but the suffix doesn’t matter.

Now, you use load to get back the values.

To load the integer:

num: load %num.r
print num
123

To load the string:

name: load %name.r
print name
Tom Smith
Advertisements
Categories: Storing Data Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: