
Quote from noyzen on July 15, 2019, 8:57 amHello,
I have a simple list box which users adds items in it at runtime...
how can i save inserted data to local storage?
i tried to save the "Items Variable" which is an array, but when i open app and use "GetData" to read it every letter will be an record in list...
for example i added 1 word like "Phone" to list and when i load it it will be like:
P
h
o
n
eHow can i save and read items of a list using local storage?
Thanks :)
Hello,
I have a simple list box which users adds items in it at runtime...
how can i save inserted data to local storage?
i tried to save the "Items Variable" which is an array, but when i open app and use "GetData" to read it every letter will be an record in list...
for example i added 1 word like "Phone" to list and when i load it it will be like:
P
h
o
n
e
How can i save and read items of a list using local storage?
Thanks :)

Quote from luishp on July 15, 2019, 12:36 pmCan you share the code you are using to store and retrieve the values or a sample .neoapp file?
Thanks!
Can you share the code you are using to store and retrieve the values or a sample .neoapp file?
Thanks!

Quote from noyzen on July 15, 2019, 2:33 pmSure! i wanted to do it but app was in Persian,
i will make a simple English app so it can be useful for other users too.
Sure! i wanted to do it but app was in Persian,
i will make a simple English app so it can be useful for other users too.

Quote from noyzen on July 15, 2019, 2:45 pm<?xml version="1.0" encoding="utf-8"?> <Application> <AppTitle>Untitled Application</AppTitle> <DesignDeviceName>Desktop</DesignDeviceName> <Variables>[list],[myitems],[mylist]</Variables> <VariablesScanned>True</VariablesScanned> <PageWidth>640</PageWidth> <PageHeight>480</PageHeight> <AutoSizeWidth>False</AutoSizeWidth> <AutoSizeHeight>False</AutoSizeHeight> <HideScrollbars>False</HideScrollbars> <PublishPlatform>WebApp</PublishPlatform> <EmptyBuildFolder>False</EmptyBuildFolder> <LanguageCode>en</LanguageCode> <MobileOSTypes>[AndroidOS,iOS,WindowsPhoneOS]</MobileOSTypes> <WindowState>normal</WindowState> <TitleBar>True</TitleBar> <Sizeable>True</Sizeable> <MaximizeBtn>False</MaximizeBtn> <MinimizeBtn>True</MinimizeBtn> <SystemMenu>True</SystemMenu> <ContextMenu>False</ContextMenu> <AlwaysOnTop>False</AlwaysOnTop> <ShowInTaskbar>True</ShowInTaskbar> <SingleInstance>False</SingleInstance> <ChromeKioskMode>False</ChromeKioskMode> <Components> <FunctionList name="Subroutines"/> <LibraryList name="Libraries"/> <PageList name="Main"> <Components> <Page id="NewPage"> <Components> <Listbox id="Listbox1"> <left>63px</left> <top>56px</top> <width>278px</width> <height>357px</height> <items>[myitems]</items> <variable>[mylist]</variable> <multi_select>False</multi_select> </Listbox> <PushButton id="PushButton1"> <left>403px</left> <top>273px</top> <width>157px</width> <height>64px</height> <caption>Save List</caption> <click>SetItem "mylist" [myitems]</click> </PushButton> <PushButton id="PushButton2"> <left>404px</left> <top>352px</top> <width>157px</width> <height>64px</height> <caption>Load List</caption> <click>GetItem "mylist" [myitems]</click> </PushButton> <PushButton id="PushButton3"> <left>408px</left> <top>52px</top> <width>157px</width> <height>64px</height> <caption>Make Empty Array</caption> <click>CreateEmptyArray [myitems]</click> </PushButton> <PushButton id="PushButton4"> <left>407px</left> <top>137px</top> <width>157px</width> <height>64px</height> <caption>Add Items to List</caption> <click>ArrayAddItem [myitems] "random word" ArrayAddItem [myitems] "hi Luis" ArrayAddItem [myitems] "VisualNEO Web" ArrayAddItem [myitems] "what can you do" ArrayAddItem [myitems] "lets make it fun" ArrayAddItem [myitems] "what is this record" ArrayAddItem [myitems] "i add one more" ArrayAddItem [myitems] "this is last one"</click> </PushButton> </Components> </Page> </Components> </PageList> <PageList name="Master"> <Components> <Page id="MasterPage"/> </Components> </PageList> <PageList name="Dialog"> <Components> <Page id="NewDialog"> <Components> <DialogContainer id="DialogContainer1"> <left>0px</left> <top>0px</top> <width>640px</width> <height>480px</height> <close_button>False</close_button> </DialogContainer> </Components> </Page> </Components> </PageList> </Components> </Application>Here is .neoapp file codes.
<?xml version="1.0" encoding="utf-8"?>
<Application>
<AppTitle>Untitled Application</AppTitle>
<DesignDeviceName>Desktop</DesignDeviceName>
<Variables>[list],[myitems],[mylist]</Variables>
<VariablesScanned>True</VariablesScanned>
<PageWidth>640</PageWidth>
<PageHeight>480</PageHeight>
<AutoSizeWidth>False</AutoSizeWidth>
<AutoSizeHeight>False</AutoSizeHeight>
<HideScrollbars>False</HideScrollbars>
<PublishPlatform>WebApp</PublishPlatform>
<EmptyBuildFolder>False</EmptyBuildFolder>
<LanguageCode>en</LanguageCode>
<MobileOSTypes>[AndroidOS,iOS,WindowsPhoneOS]</MobileOSTypes>
<WindowState>normal</WindowState>
<TitleBar>True</TitleBar>
<Sizeable>True</Sizeable>
<MaximizeBtn>False</MaximizeBtn>
<MinimizeBtn>True</MinimizeBtn>
<SystemMenu>True</SystemMenu>
<ContextMenu>False</ContextMenu>
<AlwaysOnTop>False</AlwaysOnTop>
<ShowInTaskbar>True</ShowInTaskbar>
<SingleInstance>False</SingleInstance>
<ChromeKioskMode>False</ChromeKioskMode>
<Components>
<FunctionList name="Subroutines"/>
<LibraryList name="Libraries"/>
<PageList name="Main">
<Components>
<Page id="NewPage">
<Components>
<Listbox id="Listbox1">
<left>63px</left>
<top>56px</top>
<width>278px</width>
<height>357px</height>
<items>[myitems]</items>
<variable>[mylist]</variable>
<multi_select>False</multi_select>
</Listbox>
<PushButton id="PushButton1">
<left>403px</left>
<top>273px</top>
<width>157px</width>
<height>64px</height>
<caption>Save List</caption>
<click>SetItem "mylist" [myitems]</click>
</PushButton>
<PushButton id="PushButton2">
<left>404px</left>
<top>352px</top>
<width>157px</width>
<height>64px</height>
<caption>Load List</caption>
<click>GetItem "mylist" [myitems]</click>
</PushButton>
<PushButton id="PushButton3">
<left>408px</left>
<top>52px</top>
<width>157px</width>
<height>64px</height>
<caption>Make Empty Array</caption>
<click>CreateEmptyArray [myitems]</click>
</PushButton>
<PushButton id="PushButton4">
<left>407px</left>
<top>137px</top>
<width>157px</width>
<height>64px</height>
<caption>Add Items to List</caption>
<click>ArrayAddItem [myitems] "random word"
ArrayAddItem [myitems] "hi Luis"
ArrayAddItem [myitems] "VisualNEO Web"
ArrayAddItem [myitems] "what can you do"
ArrayAddItem [myitems] "lets make it fun"
ArrayAddItem [myitems] "what is this record"
ArrayAddItem [myitems] "i add one more"
ArrayAddItem [myitems] "this is last one"</click>
</PushButton>
</Components>
</Page>
</Components>
</PageList>
<PageList name="Master">
<Components>
<Page id="MasterPage"/>
</Components>
</PageList>
<PageList name="Dialog">
<Components>
<Page id="NewDialog">
<Components>
<DialogContainer id="DialogContainer1">
<left>0px</left>
<top>0px</top>
<width>640px</width>
<height>480px</height>
<close_button>False</close_button>
</DialogContainer>
</Components>
</Page>
</Components>
</PageList>
</Components>
</Application>
Here is .neoapp file codes.

Quote from luishp on July 15, 2019, 10:38 pm@noyzen you can't save an array into a LocalStorage variable.
The solution is converting the array content to a JSON string and then save it.
For reading the information back to an array just use ParseJSON.For saving the data:
StringifyJSON [myitems] [myitems2] SetItem "mylist" [myitems2]For loading the data back to an array:
GetItem "mylist" [myitems2] ParseJSON "[myitems2]" [myitems]Let me know if it works for you.
Regards.
@noyzen you can't save an array into a LocalStorage variable.
The solution is converting the array content to a JSON string and then save it.
For reading the information back to an array just use ParseJSON.
For saving the data:
StringifyJSON [myitems] [myitems2] SetItem "mylist" [myitems2]
For loading the data back to an array:
GetItem "mylist" [myitems2] ParseJSON "[myitems2]" [myitems]
Let me know if it works for you.
Regards.

Quote from noyzen on July 15, 2019, 10:58 pm[SOLVED] Perfect!
thats working now, and exactly like i wanted.
Thanks for help :)
Note: Where local data will save and how can i back up them? (Android App)
[SOLVED] Perfect!
thats working now, and exactly like i wanted.
Thanks for help :)
Note: Where local data will save and how can i back up them? (Android App)

Quote from luishp on July 16, 2019, 9:40 amLocalStorage JavaScript Limitations
Note: Where local data will save and how can i back up them? (Android App)
Although LocalStorage is quite easy to use and useful in many occasions, whenever possible use a server side database to safely store and backup information. The following are limitations and also ways to NOT use localStorage:
- Do not store sensitive user information in localStorage.
- It is not a substitute for a server based database as information is only stored on the browser.
- LocalStorage is limited to 5MB across all major browsers.
- LocalStorage is quite insecure as it has no form of data protection and can be accessed by any code on your web page.
- LocalStorage is synchronous. Meaning each operation called would only execute one after the other.
Hope it helps to understand this technology better.
LocalStorage JavaScript Limitations
Note: Where local data will save and how can i back up them? (Android App)
Although LocalStorage is quite easy to use and useful in many occasions, whenever possible use a server side database to safely store and backup information. The following are limitations and also ways to NOT use localStorage:
Hope it helps to understand this technology better.
