(AGK version: 2019.12.16)
Submitted: 2020-01-12 20:43:55
// Project: SLSV 
// Created: 2020-01-12
// Tested on Android & HTML
// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "Shared Variables" )
SetWindowSize( 640,480, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 640,480 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

LoadButton = 1
	AddVirtualButton(LoadButton,192,32,64)
	SetVirtualButtonText(LoadButton,"Load")

SaveButton = 2
	AddVirtualButton(SaveButton,256,32,64)
	SetVirtualButtonText(SaveButton,"Save")
	
DeleteButton = 3
	AddVirtualButton(DeleteButton,320,32,64)
	SetVirtualButtonText(DeleteButton,"Delete")

SaveVars()

do
	If GetVirtualButtonPressed(LoadButton) = 1
		ThisWord$ = LoadWord()
		ThisNumber = LoadNumber()
	Endif
	
	If GetVirtualButtonPressed(SaveButton) = 1 
		SaveVars()
		ThisWord$ = LoadWord()
		ThisNumber = LoadNumber()
	Endif
	
	If GetVirtualButtonPressed(DeleteButton) = 1
		DeleteVariables()
		ThisWord$ = LoadWord()
		ThisNumber = LoadNumber()
	Endif
	
    Print( "Word: " + ThisWord$)
    Print( "Number: " + STR(ThisNumber))
    Sync()
loop

Function SaveVars()
	SaveSharedVariable("Word","Success!")
	SaveSharedVariable("Number",STR(1))
EndFunction

Function LoadWord()
	ThisWd$ = LoadSharedVariable("Word", "Failed")
EndFunction ThisWd$

Function LoadNumber()
	ThisNum$ = LoadSharedVariable("Number", "-1")
	Num = VAL(ThisNum$)
EndFunction Num

Function DeleteVariables()
	DeleteSharedVariable("Word")
	DeleteSharedVariable("Number")
EndFunction
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.