I wanted to try something from a previous post here, but I chose to do it in a simple command line program and I've faced a problem I don't have in a Lazarus-managed GUI programs. I have to create all objects manually, but I've find out I have no idea how to create a TField instance!
I've tried this according to the FCL documentation:
DataSet.Fields.Add(Field);
Also this, simply using the constructor, as usual:
Field := TField.Create(nil);
Whatever I did, either I got an access violation (SIGSEGV on Linux) or if I did not and then tried using the field in the dataset's Fields[n] property, I got an "index out of bounds" error even with the index being zero.
I've checke the documentation, FCL docs do have TFields documented, but it is very brief and nothing of it works in this example. The only information I found on the wiki, in the documentation about databases, is a redlink with a promise there will be explained how to programatically create fields, but so far nobody has written it.
So to recap once again, nothing that works in a GUI Lazarus app works here, and also I couldn't do it properly in the way objecs are usally managed. So, obviously there is another step required, or is something done differently . Could somebody explain how is it done? Then perhaps we could finally complete the above mentioned wiki documentation
EDIT: The dataset used was TMemDataset, so it is possible it affects the required steps...