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

🖥 Pongy game

This program is a port (and slight mod) of the QB64pe program by SierraKen.  (SierraKen's program shared with the QB64pe community in th...