LocalStorage: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
(Created page with "LOCALSTORAGE(''string'' | ''variable'') '''Description''' LOCALSTORAGE allows you to save string data so it is available next time you run the program. An entry can be creat...")
 
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
LOCALSTORAGE(''string'' | ''variable'')
localStorage(''string'' | ''variable'')


'''Description'''
== Description ==


LOCALSTORAGE allows you to save string data so it is available next time you run the program. An entry can be created by assigning to LOCALSTORAGE.''variableName'', where ''variableName'' is chosen by you. Data is retrieved the same way. A program is allowed to store at least 5 megabytes of data in LOCALSTORAGE. The information in LOCALSTORAGE is lost if the browser cache is cleared. To be certain that you do not lose data, save it into an SQLite database instead.
localStorage allows you to save string data so it is available next time you run the program. An entry can be created by assigning to localStorage.''variableName'', where ''variableName'' is chosen by you. Data is retrieved the same way. A program is allowed to store at least 5 megabytes of data in localStorage. The information in localStorage is lost if the browser cache is cleared on some devices. To be certain that you do not lose data, save it into an SQLite database instead.


LOCALSTORAGE is shared among all apps deployed from the same web server. This can be useful if you have a family of apps which need to share data.
localStorage is shared among all apps deployed from the same web server. This can be useful if you have a family of apps which need to share data.


Note that if the user has Private Browsing turned on, localStorage is not accessible.  
Note that if the user has Private Browsing turned on, localStorage is not accessible.


'''Example'''
See [[LocalStorage made Simple|LocalStorage Made Simple]].
 
== Example ==


<pre>
<pre>
REM LOCALSTORAGE Save Example
Rem localStorage Save Example
localStorage.data = "This is Data."
localStorage.data = "This is Data."
(run and exit program)
(run and exit program)
REM LOCALSTORAGE Retrieve Example
Rem localStorage Retrieve Example
Print localStorage.data
Print localStorage.data
   
   
REM Test if Private Browsing is turned on
Rem Test if Private Browsing is turned on
Try
Try
   localStorage.private = "test"
   localStorage.private = "test"
Catch err
Catch err
   MsgBox "Please turn Private Browsing on"     
   MsgBox "Please turn Private Browsing off"     
End Try
End Try
Rem Some additional samples:
localStorage.setItem("key", value) 'creates localStorage.key with defined value
localStorage["key"] = value 'alternative method for above
localStorage.getItem("key") 'calls localStorage.key...useful to check if it exists
localStorage.removeItem("key") 'deletes localStorage.key
delete localStorage.key 'alternative method for above
delete localStorage["key"] 'another alternative method for above
localStorage.clear() 'nuclear deletion of all localStorage variables in the domain. Use with care.
localStorage[DBRecords.rows.item(0)["ModsType"]] = "alpha"
</pre>
</pre>


'''Output'''
== Output ==


<pre>
<pre>
This is the Data.   1
This is Data.
</pre>
</pre>


'''Related Items'''
== Related Items ==
 
[[serverStorage| ServerStorage]], [[sessionstorage|SessionStorage]], [[sql|SQL]]
 
[[Category:Language Reference]]


[[sessionstorage|SESSIONSTORAGE]], [[sql|SQL]]
[[Category:Miscellaneous]]

Latest revision as of 20:09, 23 May 2018

localStorage(string | variable)

Description

localStorage allows you to save string data so it is available next time you run the program. An entry can be created by assigning to localStorage.variableName, where variableName is chosen by you. Data is retrieved the same way. A program is allowed to store at least 5 megabytes of data in localStorage. The information in localStorage is lost if the browser cache is cleared on some devices. To be certain that you do not lose data, save it into an SQLite database instead.

localStorage is shared among all apps deployed from the same web server. This can be useful if you have a family of apps which need to share data.

Note that if the user has Private Browsing turned on, localStorage is not accessible.

See LocalStorage Made Simple.

Example

Rem localStorage Save Example
localStorage.data = "This is Data."
(run and exit program)
Rem localStorage Retrieve Example
Print localStorage.data
 
Rem Test if Private Browsing is turned on
Try
  localStorage.private = "test"
Catch err
   MsgBox "Please turn Private Browsing off"    
End Try

Rem Some additional samples:
localStorage.setItem("key", value) 'creates localStorage.key with defined value
localStorage["key"] = value 'alternative method for above
localStorage.getItem("key") 'calls localStorage.key...useful to check if it exists 
localStorage.removeItem("key") 'deletes localStorage.key
delete localStorage.key 'alternative method for above
delete localStorage["key"] 'another alternative method for above
localStorage.clear() 'nuclear deletion of all localStorage variables in the domain. Use with care.
localStorage[DBRecords.rows.item(0)["ModsType"]] = "alpha"

Output

This is Data.

Related Items

ServerStorage, SessionStorage, SQL