Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32231 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2017-01-21 02:33 -0800 |
| Last post | 2017-01-23 02:42 -0800 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.javascript
Javascript save and load "records" jonas.thornvall@gmail.com - 2017-01-21 02:33 -0800
Re: Javascript save and load "records" "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-21 14:50 -0800
Re: Javascript save and load "records" jonas.thornvall@gmail.com - 2017-01-23 02:42 -0800
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-01-21 02:33 -0800 |
| Subject | Javascript save and load "records" |
| Message-ID | <070aece9-91e6-45c9-b984-42b3ebedbb2f@googlegroups.com> |
I found some code that both can load and save text and pictures.
But i would like some advice on how to save it like a record "format the data".
I have an array with nodes they certain properties like nodeindex, linkarray, color, position(x,y) etc
Should i just make a string of each entrance and separate with a newline?
function makeNodes()
{
for (var m = 0; m <= nodes; m ++ )
{
arr[m] ={nodeindex : 0, nroflinks : 0, nodelinks : [], hold : false, rposX : 0, rposY : 0, rwidth : 10, rheigth : 10, rcolor : "red" , bcolor : "green"};
}
return arr;
}
It seem arrays can be extracted to comma separated strings.
I guess there is nothing like a record in javascript just data types, so you have to format yourself? Will newline do for each entry?
Or is there something like a binary datatype that could be saved? I always go with the easiest option my guess it that a text string is easier to save and load back to the array?
JT
[toc] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2017-01-21 14:50 -0800 |
| Message-ID | <fcadb45d-be73-4280-b470-490abee8bf87@googlegroups.com> |
| In reply to | #32231 |
On Saturday, January 21, 2017 at 4:33:17 AM UTC-6, jonas.t...@gmail.com wrote:
> I found some code that both can load and save text and pictures.
>
> But i would like some advice on how to save it like a record "format the data".
>
> I have an array with nodes they certain properties like nodeindex, linkarray, color, position(x,y) etc
>
> Should i just make a string of each entrance and separate with a newline?
>
> function makeNodes()
> {
> for (var m = 0; m <= nodes; m ++ )
> {
> arr[m] ={nodeindex : 0, nroflinks : 0, nodelinks : [], hold : false, rposX : 0, rposY : 0, rwidth : 10, rheigth : 10, rcolor : "red" , bcolor : "green"};
> }
> return arr;
> }
>
> It seem arrays can be extracted to comma separated strings.
> I guess there is nothing like a record in javascript just data types, so you have to format yourself? Will newline do for each entry?
>
> Or is there something like a binary datatype that could be saved? I always go with the easiest option my guess it that a text string is easier to save and load back to the array?
A record is simply a data structure that can be represented as a JavaScript object. Saving the data is a different matter depending on a particular use case (server vs. client. domain vs non-domain specific, etc...)
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-01-23 02:42 -0800 |
| Message-ID | <0d4c0688-9509-4ad9-a7d3-6a7c1e8b2d0f@googlegroups.com> |
| In reply to | #32243 |
Den lördag 21 januari 2017 kl. 23:50:39 UTC+1 skrev Michael Haufe (TNO):
> On Saturday, January 21, 2017 at 4:33:17 AM UTC-6, jonas.t...@gmail.com wrote:
> > I found some code that both can load and save text and pictures.
> >
> > But i would like some advice on how to save it like a record "format the data".
> >
> > I have an array with nodes they certain properties like nodeindex, linkarray, color, position(x,y) etc
> >
> > Should i just make a string of each entrance and separate with a newline?
> >
> > function makeNodes()
> > {
> > for (var m = 0; m <= nodes; m ++ )
> > {
> > arr[m] ={nodeindex : 0, nroflinks : 0, nodelinks : [], hold : false, rposX : 0, rposY : 0, rwidth : 10, rheigth : 10, rcolor : "red" , bcolor : "green"};
> > }
> > return arr;
> > }
> >
> > It seem arrays can be extracted to comma separated strings.
> > I guess there is nothing like a record in javascript just data types, so you have to format yourself? Will newline do for each entry?
> >
> > Or is there something like a binary datatype that could be saved? I always go with the easiest option my guess it that a text string is easier to save and load back to the array?
>
> A record is simply a data structure that can be represented as a JavaScript object. Saving the data is a different matter depending on a particular use case (server vs. client. domain vs non-domain specific, etc...)
Well i just work with local files at my harddrive i was pleasantly surprised that i can both load and save text and pictures using Javascript, how long has browsers had this feature with javascript?
But i do remember the Cobol days when you simply defined a record, that you could load, save and update without knowing anything about it's structure or datatypes once you defined them. I don't know about the storage structure of the savefiles and how it was indexed but the records could be retrieved rather fast.
That would be a nice feature, well of course there is PHP, ASP and databaseconnectivity. But it seem a bit overkill sometimes.
Well maybe it is security measures of our time, i guess the minicomputer, mainframe environment with terminals wasn't exactly open to hackers by other means than telnet and modems.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web