Tower's answer to the 'searching in a string' question got me thinking about this again.
It is possible to return the value of a TStringlist in 3 ways
1. You can pass it into a procedure as a var parameter, I assume this passes a pointer to the list so there is no need to 'create' it within the procedure, and freeing it within the procedure is plainly wrong.
2. A Function can return as Result a Tstringlist created internally, but is the memory freed? You cannot 'free' the Tstringlist within the function.
Local variable are not normally 'static' so as
Towerbase's function uses the Tstringlist internally (nothing is passed out),then he frees it when its use is over, but is this necessary?
3. A Function can return as Result a TStringlist passed in as a var parameter 'Bad form' to do this?
But what are the implications?
Steve: Delphi a feersum engin indeed.
It is possible to return the value of a TStringlist in 3 ways
1. You can pass it into a procedure as a var parameter, I assume this passes a pointer to the list so there is no need to 'create' it within the procedure, and freeing it within the procedure is plainly wrong.
2. A Function can return as Result a Tstringlist created internally, but is the memory freed? You cannot 'free' the Tstringlist within the function.
Local variable are not normally 'static' so as
Towerbase's function uses the Tstringlist internally (nothing is passed out),then he frees it when its use is over, but is this necessary?
3. A Function can return as Result a TStringlist passed in as a var parameter 'Bad form' to do this?
But what are the implications?
Steve: Delphi a feersum engin indeed.