2022-04-30 03:24:36 +00:00
|
|
|
Const LOCAL = "LOCAL"
|
|
|
|
Const SESSION = "SESSION"
|
|
|
|
|
|
|
|
Export LOCAL, SESSION
|
2022-04-26 03:57:50 +00:00
|
|
|
Export Clear, Get, Key, Length, Set, Remove
|
|
|
|
|
|
|
|
$If Javascript Then
|
2023-04-18 19:32:27 +00:00
|
|
|
function _storage(stype) {
|
|
|
|
return (stype == SESSION) ? sessionStorage : localStorage;
|
|
|
|
}
|
2022-04-26 03:57:50 +00:00
|
|
|
$End If
|
|
|
|
|
|
|
|
Sub Clear (stype)
|
2023-04-18 19:32:27 +00:00
|
|
|
$If Javascript Then
|
|
|
|
_storage(stype).clear();
|
|
|
|
$End If
|
2022-04-26 03:57:50 +00:00
|
|
|
End Sub
|
|
|
|
|
|
|
|
Function Get (key, stype)
|
2023-04-18 19:32:27 +00:00
|
|
|
$If Javascript Then
|
|
|
|
var result = _storage(stype).getItem(key);
|
|
|
|
if (result == null) { result = ""; }
|
|
|
|
Get = result
|
|
|
|
$End If
|
2022-04-26 03:57:50 +00:00
|
|
|
End Function
|
|
|
|
|
|
|
|
Function Key (idx, stype)
|
2023-04-18 19:32:27 +00:00
|
|
|
$If Javascript Then
|
|
|
|
Key = _storage(stype).key(idx);
|
|
|
|
$End If
|
2022-04-26 03:57:50 +00:00
|
|
|
End Function
|
|
|
|
|
|
|
|
Function Length (stype)
|
2023-04-18 19:32:27 +00:00
|
|
|
$If Javascript Then
|
|
|
|
Length = _storage(stype).length;
|
|
|
|
$End If
|
2022-04-26 03:57:50 +00:00
|
|
|
End Function
|
|
|
|
|
|
|
|
Sub Set (key, value, stype)
|
2023-04-18 19:32:27 +00:00
|
|
|
$If Javascript Then
|
|
|
|
_storage(stype).setItem(key, value);
|
|
|
|
$End If
|
2022-04-26 03:57:50 +00:00
|
|
|
End Sub
|
|
|
|
|
|
|
|
Sub Remove (key, stype)
|
2023-04-18 19:32:27 +00:00
|
|
|
$If Javascript Then
|
|
|
|
_storage(stype).removeItem(key);
|
|
|
|
$End If
|
2022-04-26 03:57:50 +00:00
|
|
|
End Sub
|