Can I get a list of variables declared inside a script? I would like to implement an autocomplete feature in my app, and it would be nice to know user-defined variable names and their types.
A list of user-defined procedures/functions is also needed.
Good question. TPSExec has this info but not currently exposed:
functions should be accessible with GetProcCount and GetProc.
Variables aren’t currently exposed but can be if you create an accessor for ExportedVars:
function TPSExec.GetVar(const Name: tbtString): Cardinal;
var
l: Longint;
h: longint;
s: tbtString;
p: PPSExportedVar;
begin
s := FastUpperCase(name);
h := MakeHash(s);
for l := FExportedVars.Count - 1 downto 0 do
begin
p := FexportedVars.Data^[L];
if (p^.FNameHash = h) and(p^.FName=s) then
begin
Result := L;
exit;
end;
end;
Result := InvalidVal;
end;