@@ -84,22 +84,60 @@ var sourceCode : string;
8484
8585
8686function searchHelp (const helpStr : string) : string;
87- var i, index : integer;
87+ var i, j, index : integer;
88+ astr : TArray<string>;
89+ symbol1, symbol2: TSymbol;
8890begin
89- if helpstr = ' ?' then
91+ // Search places for any help whcih will be of the form X or X.Y
92+ astr := SplitString(helpStr, ' .' );
93+ if length (astr) = 1 then
9094 begin
91- result := ' Builtin functions:' + sLineBreak;
92- // result := builtinList[0].name;
93- // for i := 1 to builtinList.Count - 1 do
94- // result := result + ', ' + builtinList[i].name;
95- exit;
95+ // Its either in the global space or its a module name
96+ if mainModule.symbolTable.find(astr[0 ], symbol1) then
97+ begin
98+ if symbol1.symbolType = symModule then
99+ result := symbol1.mValue.helpStr
100+ else
101+ result := ' Unable to locate symbol' ;
102+ end
103+ else
104+ begin
105+ // Check the global space
106+ if mainModule.symbolTable.find(TSymbol.globalId, symbol1) then
107+ begin
108+ if symbol1.mValue.symbolTable.find(astr[0 ], symbol2) then
109+ begin
110+ result := symbol2.fValue.helpStr;
111+ end
112+ else
113+ result := ' Unable to locate symbol' ;
114+ end
115+ else
116+ result := ' Internal error: global space could not be located' ;
117+ end ;
118+ end
119+ else
120+ begin
121+ if length (astr) = 2 then
122+ begin
123+ if mainModule.symbolTable.find(astr[0 ], symbol1) then
124+ begin
125+ if symbol1.symbolType = symModule then
126+ begin
127+ if symbol1.mValue.symbolTable.find (astr[1 ], symbol2) then
128+ case symbol2.symbolType of
129+ symUserFunc : result := symbol2.fValue.helpStr;
130+ else
131+ result := symbol2.helpStr
132+ end ;
133+ end ;
134+ end
135+ else
136+ result := ' Unable to locate the module: ' + astr[0 ];
137+ end
138+ else
139+ result := ' Don'' t know how to search what you indicated: ' + helpstr;
96140 end ;
97-
98- // Search places for any help
99- // if builtinList.find(helpStr, index) then
100- // result := builtinList[index].helpStr
101- // else
102- // result := 'No help found';
103141end ;
104142
105143
0 commit comments