RESTORE: Your DATA Time Machine

RESTORE: Your DATA Time Machine

Ever wished you could rewind your READ command and start over from the beginning of your DATA list Meet RESTORE, your trusty DATA time machine! This handy command resets the internal pointer that keeps track of where you are in your DATA statements, allowing you to reread values as many times as you need. Think of it as a bookmark for your data!

Syntax

RESTORE 

(That's it! No parameters needed.)

Applications

The RESTORE command is your go-to tool when:

  • Reusing DATA: You want to read the same values from a DATA statement multiple times in your program.
  • Processing data in different orders: You need to access the same data in various ways, such as sorting or filtering.
  • Creating dynamic data structures: You can use RESTORE to reload initial values or reset data structures during program execution.

Code Examples

1. Simple Data Restore:

10 rem RESTORE demostration
20 DATA 10, 20, 30, 40, 50
30 READ A, B, C
40 PRINT "initial values: "; A; B; C
50 RESTORE 
60 READ D
70 PRINT "final values: "; D : rem output: 10

This example shows how RESTORE allows you to read the values from the DATA statement again.

1. Same Example Commented Restore:

10 rem RESTORE demostration
20 DATA 10, 20, 30, 40, 50
30 READ A, B, C
40 PRINT "initial values: "; A; B; C
50 REM RESTORE 
60 READ D
70 PRINT "final values: "; D : rem output: 40

Here, the commented RESTORE doesn't reset the pointer to the 4th DATA position, so subsequent READ commands will start from there.

RESTORE in the Wild: The High Score Keeper

Imagine you're building a game with a high score table. You could use DATA to store the top scores and names, and then use RESTORE and READ in a loop to display the high score table each time the game ends.

Don't let your DATA be a one-time-use resource! With RESTORE, you can rewind and reuse your data as many times as you need, opening up new possibilities for data manipulation and reuse in your Commodore 64 programs. It's like having a rewind button for your data, giving you the flexibility to access and process it in creative ways. So don't be afraid to experiment with RESTORE and unlock the full potential of your DATA statements!


Privacy Policy

Let's be honest, we collect some data. But we promise not to sell it, we'll mostly use it to improve our service. You can read the nitty-gritty details below, but be warned, it uses big words that lawyers like (we don't judge).

By using our service, you agree to this privacy policy. This disclaimer strikes a balance between lightheartedness and informing users that they should still read the full privacy policy if they choose.