; CopyBank Example ; ---------------- ; A player save record packed into an 11 byte bank: ; flags (byte=1) + hp (short=2) + score (int=4) + x_pos (float=4) save=CreateBank(11) PokeByte save,0,5 PokeShort save,1,250 PokeInt save,3,1234567 PokeFloat save,7,17.25 Print "Checkpoint reached: hp = "+PeekShort(save,1)+" score = "+PeekInt(save,3) ; Take a checkpoint - CopyBank copies all 11 bytes into a backup bank backup=CreateBank(11) CopyBank save,0,backup,0,11 Print "Record backed up with CopyBank" ; Disaster strikes - the live record gets trashed PokeShort save,1,10 PokeInt save,3,0 Print "" Print "After taking damage: hp = "+PeekShort(save,1)+" score = "+PeekInt(save,3) ; Restore the checkpoint - copy the backup over the live record CopyBank backup,0,save,0,11 Print "" Print "Restored from backup: hp = "+PeekShort(save,1)+" score = "+PeekInt(save,3) FreeBank backup FreeBank save Print "" Print "Press any key to close the example" WaitKey End