Recent

Author Topic: I need some Pascalish method for saving the state of grids to disk.  (Read 12696 times)

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #15 on: March 11, 2013, 10:41:48 am »
@TurboRascal you do understand that he uses the json only to dump the objects on screen so he can check that everything worked right?

In that case, I guess I read the thread too fast  :-[

The CSV or fixed records proposition still stands though ;)
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

vfclists

  • Hero Member
  • *****
  • Posts: 1146
    • HowTos Considered Harmful?
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #16 on: March 11, 2013, 04:52:01 pm »
Thanks for the example. It is able to load the compnent back. In your previous post you mentioned something about not being able to add more entries to it.

Basically once it is streamed in I want to be able to add more items to it. Is there any extra work required, I mean apart from loading it adding more items to it like in he example, or deleting those there is there anything else to look out for?

I have fixed your sample, it now saves and loads the components, haven't tested to see if they are the same primarily because I use the same trick in my own collections and I know it works. I tried to make sure that there are no memory leaks but you should check it out your self.
Lazarus 3.0/FPC 3.2.2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #17 on: March 11, 2013, 04:58:31 pm »
You can add/delete and save as many CollectionItems as you want you can't mix different collectionItem classes in one collection eg. 2 differnt types of TColumnCollectionItem one that has Property1:Double, Propert2:Integer and a second one that has Property1: Datatime; Property2:integer; Property3:string;

Each collection must have only one itemclass.
the collection depends on a single TCollectionItem class to do its streamming.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

gulyone

  • Guest
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #18 on: March 11, 2013, 05:36:24 pm »
all that sounds good for a little grid and a sequential reading ... no matter with master-childs of different sizes on disk.

pushing the problem , if i need for example to just extract the 1517 'componentwriten' element in a file of about 4000 elements , each one having variable lengths , and many users do the same kind of request, my server is going to be spanked

suggestion = maintain an indexes file alongside
« Last Edit: March 11, 2013, 05:50:25 pm by gulyone »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #19 on: March 11, 2013, 06:04:18 pm »
In your case take a look on my recent efforts to port the gpstructurestorage components its a file system in a file it has a hierarchical structure (folders, files).

This kind of files that the OP wants are an all or nothing type of thing loaded once and used through out the life of the form they represent.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

vfclists

  • Hero Member
  • *****
  • Posts: 1146
    • HowTos Considered Harmful?
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #20 on: March 16, 2013, 10:02:13 pm »
I see that VTV is one of the components you are familiar with. I am want to see if I can use it in combination with some grids to display the master/detail nature of the records. Do you have some tips along those lines/
You can add/delete and save as many CollectionItems as you want you can't mix different collectionItem classes in one collection eg. 2 differnt types of TColumnCollectionItem one that has Property1:Double, Propert2:Integer and a second one that has Property1: Datatime; Property2:integer; Property3:string;

Each collection must have only one itemclass.
the collection depends on a single TCollectionItem class to do its streamming.
Lazarus 3.0/FPC 3.2.2

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11941
  • FPC developer.
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #21 on: March 16, 2013, 10:13:43 pm »
Afaik the most clean way would not to use the grid, but the underlying tdataset. Pump the relevant records over into a tbufdataset, and use the fairly new importers/exporters (2.6.2?) to save/load them to and from disk.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #22 on: March 16, 2013, 10:42:24 pm »
I see that VTV is one of the components you are familiar with. I am want to see if I can use it in combination with some grids to display the master/detail nature of the records. Do you have some tips along those lines/

I haven't done any master-detail development with vtv although it is on my todo list for the time being I'm using it for custom tree like structures and such, mostly non db aware code. Before I start using it on master detail  I want to extend it to support
1) multiple headers
2) merged cells
1st and that will take some time.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

vfclists

  • Hero Member
  • *****
  • Posts: 1146
    • HowTos Considered Harmful?
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #23 on: May 27, 2013, 10:40:38 pm »
This thread has been some time, but in relation to the JSON and objects issue is there some way an object can be created from JSON at runtime?
It looks to me like it won't be possible for all objects, but perhaps it will be possible for simpler object types, and the JSON will require some extra data encoded as hints.

Is there anything in the FreePascal libraries capable of this, or useful as a starting point?
Lazarus 3.0/FPC 3.2.2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: I need some Pascalish method for saving the state of grids to disk.
« Reply #24 on: May 27, 2013, 11:04:22 pm »
well lcl streaming already uses the registerclass/findclass group of procedures to dynamically create components you can take a look how that works and use it.
Just in case I misunderstood it is impossible to create an object that the executable has no knowledge about.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018