Hi,
How can i list all classes defined in script? ( I mean like{$FORM TDiscounttest, discounttest1.sfm} )
I tried with scripter.Classes, but I couldn't see my script class.
Purpose is to list all methods in class, extract all which name starts with specific string and give list to user so he/she can select method to execute.
The forms appear as classes normally, but of course you must compile the script first.
Here is a rough test that works in the existing Forms demo (demos\forms folder) which lists the existing script forms and their methods:
procedure TForm1.Button1Click(Sender: TObject);
begin
FRunScript.SourceCode := ScrMemo1.Lines;
FRunScript.Compile;
ScrMemo1.Lines.Clear;
var StrList := ScrMemo1.Lines;
for var I := 0 to atScripter1.Classes.Count - 1 do
begin
var C := atScripter1.Classes[I];
if C.ClassRef.InheritsFrom(TScriptForm) and not SameText(C.Name, 'TScriptForm') then
begin
StrList.Add(C.Name + ': ' + C.ClassRef.ClassName);
for var J := 0 to C.Methods.Count - 1 do
StrList.Add(' ' + C.Methods[J].Name);
end;
end;
end;
1 Like
It worked in my app, had only add check if assigned(c.Classref) ...
thanks again!
1 Like
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.