Sample WinCC Flexible VBscript code for saving and restoring complete Datablocks (DB's) in an S7 PLC.

The DB's will be stored in a text file (.bak extension) on the PC's harddrive.

The code will work with a PC RT. 
For a CE panel to store on its removable flash card, you must modify the code to work with Windows CE.

The code is based on this Siemens sample project:
http://support.automation.siemens.com/WW/view/en/26106419
The difference between my code, and Siemens sample project code is that in Siemens code you save and restore individual tags, whereas in my code you save and restore complete DBs.

So what can this be used for ?
It can be used to restore machine settings after downloading a new PLC program !
It can be used to restore machine settings after exchanging the PLC program via a flashcard sent in the mail !
It can be used to restore known good machine settings after after they have become messed up through operator error !
It can be used to restore machine settings after the actual values have become corrupted and thereforereset to initial values (can happen from noise or power glitches) !
It can be used to make a snapshot of DB content that can then be sent to the programmer. The programmer can then troubleshoot the machine by means of the DB content.
It can be used to send modified DB content to a customer. The customer can then download the modified DB's to the machine !

How can you NOT need this !

It could also be used to create a kind of recipe function, however, this was not my intention. Siemens original sample project is probably better for this purpose.

Other notes:

You have to create array tags for all the DB's you want to save/restore. So each DB will "cost" a powertag.

The saved data will appear as INTs in the text file. It is therfore not readily interprettable if the data in the source DB are not INTs. There are also no symbols or comments.
To examine the data with the proper formatting as well as symbols and comments, you have to restore the data into the DB's of the correct S7 project. To this purpose PLCSIM can be used for example.

The code can still be tidied up a bit. You cannot avoid having to make one save script and one restore script per DB though (unless you cram the handling of all DBs into one script). The reason is that I do not think you can pass the array tag to save and restore dynamically.

I have configured a string "strStatusMessage" that can be displayed on the HMI. It is a matter of preference if you favor to use "ShowSystemMessage".

The files are:
Description_DB_save_restore.txt, this file.
Tags.txt, tags used in the WinCC Flexible project.
CopyDB1FromPLCToFile.txt, script code for saving DB1 to file.
CopyDB1FromFileToPLC.txt, script code for restoring DB1 to PLC.
CopyDB2FromPLCToFile.txt, script code for saving DB2 to file.
CopyDB2FromFileToPLC.txt, script code for restoring DB2 to PLC.

Jesper M. Pedersen
June 2008

