I had an issue that Wagner (thanks!) resolved for me in email - decided to post here in case it can help anyone else.
In a script where I'd registered TClientDataSet, when I tried to get a StringList to SaveToFile('somefile.txt') it would fail asking for a second parameter (TEncoding value).
To reproduce my issue:
In the ScripterProIDE sample, add to "uses":
System.TypInfo,
Data.DB,
Datasnap.DBClient,
Then add to "FormCreate":
IDEScripter1.DefineClassByRTTI(TClientDataSet, '', [mvpublic, mvpublished],true);
Run project, drop a button on Form2, and this code:
procedure Button1Click(Sender: TObject);
var
fList : TStringList;
begin
fList:=TStringlist.create;
FList.add('Blah');
flist.SaveToFile('eraseme.txt');
flist.free;
end;
When you try and run you get the error about needing 2 params.
Wagner indicated "... that is expected. Simply, one call (DefineClassByRTTI) overwrites the other (imported class in ap_Classes) and suggested:
1. Move the DefineClassByRTTI to later, for example, right before IDEDialog1.Execute
2. Call this way:
IDEScripter1.DefineClassByRTTI(TClientDataSet, '', [mvpublic, mvpublished], true,
TRedefineOption.roInclude);
3. Simply redefine the SaveToClient method manually using the number of parameters you want.
Because my code is actually in a library, I opted for 2) above.
That is, in demo project, changing that FormCreate line to: :
IDEScripter1.DefineClassByRTTI(TClientDataSet, '', [mvpublic, mvpublished], true,
TRedefineOption.roInclude);
solved the StringList.SaveToFile param issue for me.
Cheers,
EdB