mirror of
https://github.com/boxgaming/qbjs.git
synced 2024-09-20 04:24:45 +00:00
43 lines
No EOL
770 B
QBasic
43 lines
No EOL
770 B
QBasic
Export Clear, Get, Key, Length, Set, Remove
|
|
|
|
$If Javascript Then
|
|
function _storage(stype) {
|
|
return (stype == QB.SESSION) ? sessionStorage : localStorage;
|
|
}
|
|
$End If
|
|
|
|
Sub Clear (stype)
|
|
$If Javascript Then
|
|
_storage(stype).clear();
|
|
$End If
|
|
End Sub
|
|
|
|
Function Get (key, stype)
|
|
$If Javascript Then
|
|
Get = _storage(stype).getItem(key);
|
|
$End If
|
|
End Function
|
|
|
|
Function Key (idx, stype)
|
|
$If Javascript Then
|
|
Key = _storage(stype).key(idx);
|
|
$End If
|
|
End Function
|
|
|
|
Function Length (stype)
|
|
$If Javascript Then
|
|
Length = _storage(stype).length;
|
|
$End If
|
|
End Function
|
|
|
|
Sub Set (key, value, stype)
|
|
$If Javascript Then
|
|
_storage(stype).setItem(key, value);
|
|
$End If
|
|
End Sub
|
|
|
|
Sub Remove (key, stype)
|
|
$If Javascript Then
|
|
_storage(stype).removeItem(key);
|
|
$End If
|
|
End Sub |