Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread TPersistantStorage / LocalStorage
Sat, Sep 28 2013 1:55 PMPermanent Link

Ralf Bertoldi

I built a small client side app and wanted to store some data.
So, I tried it with the LocalStorage.

The documentation says it's possible to access the Items by name or index.
But access by Index is always empty (?).

procedure TForm1.Form1Show(Sender: TObject);
var
 i:integer;
begin
 LocalStorage.Set('first', 'data1');
 LocalStorage.Set('sercond', 'data2');
 LocalStorage.Set('third', 'data3');

 //  working
 ShowMessage('first: '+Localstorage.Items['first']);

 // doesn't work.
 for i := 0 to LocalStorage.Count - 1 do  
   ShowMessage(inttostr(i)+': '+Localstorage.Items[i]);
   
end;

Maybe I missed something? If so, how can I see the key value (of the key/Value pairs) when I use the Index?

regards,
Ralf

Ok,.. after playing around I searched the web for some information and found a very basic example how to use the storage functionality. It's javascript but easy to port.
It was very helpful for me. A way to put data in groups with an own index,..
http://www.diveintojavascript.com/tutorials/web-storage-tutorial-creating-an-address-book-application
Sat, Sep 28 2013 4:13 PMPermanent Link

Raul

Team Elevate Team Elevate

On 9/28/2013 1:55 PM, Ralf Bertoldi wrote:
> I built a small client side app and wanted to store some data.
> So, I tried it with the LocalStorage.
>
> The documentation says it's possible to access the Items by name or index.
> But access by Index is always empty (?).
> Maybe I missed something? If so, how can I see the key value (of the key/Value pairs) when I use the Index?
>

Tried it and this looks like a bug to me - we'll see what Tim says.

Raul
Mon, Sep 30 2013 4:22 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ralf,

<< But access by Index is always empty (?). >>

It's a bug.  The fix is this:

WebCore unit:

function TPersistentStorage.GetItem(Index: Integer): String;
begin
  CheckAvailable;
  Result:=FStorage[FStorage.key(Index)];  <<<<< This
  if (Result=nil) then
     Result:='';
end;

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Oct 17 2013 11:12 PMPermanent Link

Ralf Bertoldi

Tim,
Suggestion: would it be possible to access the "key" value of the "key/value" pair
in the core like:

function TPersistentStorage.GetKey(Index: Integer): String;
begin
  CheckAvailable;
  Result:=FStorage.key(Index);
  if (Result=nil) then
     Result:='';
end;

Sometimes I'm searching for a special "key" value... by index and hope to find the key.

regards,
Ralf


"Tim Young [Elevate Software]" wrote:

Ralf,

<< But access by Index is always empty (?). >>

It's a bug.  The fix is this:

WebCore unit:

function TPersistentStorage.GetItem(Index: Integer): String;
begin
  CheckAvailable;
  Result:=FStorage[FStorage.key(Index)];  <<<<< This
  if (Result=nil) then
     Result:='';
end;

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Oct 24 2013 4:31 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ralf,

<< Suggestion: would it be possible to access the "key" value of the
"key/value" pair in the core like: >>

Sure, I'll add it to the list for the next build.

Tim Young
Elevate Software
www.elevatesoft.com
Image