Monday, July 31, 2023

🆕 RemoveLocalStorageItem and ClearLocalStorage

(Latest version of BASIC Anywhere Machine.)

Sample program to demo all of the local storage statements and function:

LET userName$ = GetLocalStorageItem("Prog1: userName" )

LET CountProgramRuns% = VAL( GetLocalStorageItem("Prog1: runCount" ) )  + 1
SetLocalStorageItem("Prog1: runCount" , CountProgramRuns%)

IF userName$ = "" THEN
    WHILE userName$ = "" : userName$ = _PROMPT(" Enter your user name", "") : WEND
    SetLocalStorageItem("Prog1: userName" , userName$)
END IF

PRINT "Hello, " + userName$
PRINT "This program has been run " + str$(CountProgramRuns%) + " times."

SLEEP 2
IF NOT _CONFIRM("Maintain your name in local storage?") _
   THEN RemoveLocalStorageItem("Prog1: userName")
   
IF _CONFIRM("Clear local storage?") _
   THEN PRINT "PRESS A KEY TO CLEAR LOCAL STORAGE": temp$ = INPUT$(1) : ClearLocalStorage


No comments:

Post a Comment

📚 A BAM Use-Case: Giving a New Lease on Life to Old BASIC Programs

One BAM's top goals is to make it fairly easy to port old BASIC programs so that they can be shared via the web for running in any web b...