|Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread|
|Messages 1 to 3 of 3 total|
|undefined value from storage|
|Wed, May 1 2013 2:30 AM||Permanent Link|
I try to read a string from local storage. If it's not defined, ADefault should be returned. How do I have to check the Result on undefined value?
function BSGetLocalString(const AName: String; const ADefault: String = ''): String;
Result := window.localStorage.items[AName];
if Result = 'undefined'
then Result := ADefault;
|Wed, May 1 2013 5:09 AM||Permanent Link|
What I chose to do was have a value that shows if I have initialised the local
storage (saved anything).
szInitialiseCheck := Window.LocalStorage.GetItem('store_initialised');
if szInitialiseCheck = '1' then
// read the rest
Given that the value won't be '1' if I didn't save it, then this works for me. It
would be good to have a better solution though. I think Tim said he was going to
enhance this at some point, not sure if it is for next update.
|Fri, May 3 2013 9:46 AM||Permanent Link|
Tim Young [Elevate Software]
Elevate Software, Inc.
<< I try to read a string from local storage. If it's not defined, ADefault
should be returned. How do I have to check the Result on undefined value? >>
Compare against nil:
TempValue := window.localStorage.items['Test'];
if (TempValue=nil) then
This web page was last updated on
Wednesday, March 29, 2023 at 12:35 AM
© 2023 Elevate Software, Inc. All Rights Reserved
Questions or comments ? E-mail us at email@example.com