Discussion:
adding user defined functions to foxcode
(too old to reply)
Kevin Clark
2011-04-04 15:09:21 UTC
Permalink
I have a PRG of standard procedures which has a few hundred procedures
and functions that I use all the time. Since it has so many
functions, it's easy to forget the syntax of each function.
Fortunately, the functions can be added to the FoxCode table so that I
am prompted with the correct parameters. I recently wrote a short
program to scan a PRG and add all functions/procedures to FoxCode. I
have copied the program into this post. 1) use at your own risk, 2)
feel free to improve it.

CREATE TABLE functions (name C(80),parameters C(200))
&& creates the table to hold function names and parameters
&& you can increase field sizes if necessary

local array aParse(1)
for ix = 1 to ALines( aParse, FileToStr("<Put Your PRG filename
here>"))
tmpLine=ALLTRIM(AParse[m.ix])
IF LEFT(tmpline,2)<>"&"+"&" AND left(tmpline,1)<>"*" THEN
IF AT("PROCEDURE",UPPER(tmpline))>0 OR
AT("FUNCTION",UPPER(tmpline))>0 THEN

tmpStartPlace=IIF(AT("PROCEDURE",UPPER(tmpline))>0,AT("PROCEDURE",UPPER(tmpline))
+9,AT("FUNCTION",UPPER(tmpline))+8)
IF AT("(",tmpLine)>0 THEN
tmpFuncName=SUBSTR(tmpline,tmpStartPlace,AT("(",tmpLine)-
tmpStartPlace)
tmpPrompt=RIGHT(tmpLine,LEN(tmpline)-AT("(",tmpLine))
IF at(")",tmpPrompt)>0 then
tmpEnd=at(")",tmpPrompt)
tmpPrompt=LEFT(tmpPrompt,tmpEnd-1)
ENDIF
ELSE
tmpFuncName=RIGHT(tmpLine,LEN(tmpLine)-tmpStartPlace)
IF AT("PARAMETERS",aparse(m.ix+1))>0 then
tmpPrompt=RIGHT(aparse(m.ix+1),LEN(aparse(m.ix+1))-11)
ELSE
tmpPrompt=""
ENDIF
ENDIF
INSERT INTO functions(name,parameters) VALUES
(tmpFuncName,tmpPrompt)
ENDIF
ENDIF
ENDFOR

USE "<put your foxcode table name here>" alias foxcode IN 0
SELECT functions
GO TOP
SCAN
INSERT INTO foxcode (type,expanded,cmd,tip,case,timestamp,uniqueid)
VALUES ;

("F",ALLTRIM(functions.name),"{funcmenu2}",ALLTRIM(functions.parameters),"M",DATETIME(),SYS(2015))
SELECT functions
ENDSCAN
Paul Pedersen
2011-09-24 03:05:53 UTC
Permalink
Thanks, I'll check it out.
Post by Kevin Clark
I have a PRG of standard procedures which has a few hundred procedures
and functions that I use all the time. Since it has so many
functions, it's easy to forget the syntax of each function.
Fortunately, the functions can be added to the FoxCode table so that I
am prompted with the correct parameters. I recently wrote a short
program to scan a PRG and add all functions/procedures to FoxCode. I
have copied the program into this post. 1) use at your own risk, 2)
feel free to improve it.
CREATE TABLE functions (name C(80),parameters C(200))
&& creates the table to hold function names and parameters
&& you can increase field sizes if necessary
local array aParse(1)
for ix = 1 to ALines( aParse, FileToStr("<Put Your PRG filename
here>"))
tmpLine=ALLTRIM(AParse[m.ix])
IF LEFT(tmpline,2)<>"&"+"&" AND left(tmpline,1)<>"*" THEN
IF AT("PROCEDURE",UPPER(tmpline))>0 OR
AT("FUNCTION",UPPER(tmpline))>0 THEN
tmpStartPlace=IIF(AT("PROCEDURE",UPPER(tmpline))>0,AT("PROCEDURE",UPPER(tmpline))
+9,AT("FUNCTION",UPPER(tmpline))+8)
IF AT("(",tmpLine)>0 THEN
tmpFuncName=SUBSTR(tmpline,tmpStartPlace,AT("(",tmpLine)-
tmpStartPlace)
tmpPrompt=RIGHT(tmpLine,LEN(tmpline)-AT("(",tmpLine))
IF at(")",tmpPrompt)>0 then
tmpEnd=at(")",tmpPrompt)
tmpPrompt=LEFT(tmpPrompt,tmpEnd-1)
ENDIF
ELSE
tmpFuncName=RIGHT(tmpLine,LEN(tmpLine)-tmpStartPlace)
IF AT("PARAMETERS",aparse(m.ix+1))>0 then
tmpPrompt=RIGHT(aparse(m.ix+1),LEN(aparse(m.ix+1))-11)
ELSE
tmpPrompt=""
ENDIF
ENDIF
INSERT INTO functions(name,parameters) VALUES
(tmpFuncName,tmpPrompt)
ENDIF
ENDIF
ENDFOR
USE "<put your foxcode table name here>" alias foxcode IN 0
SELECT functions
GO TOP
SCAN
INSERT INTO foxcode (type,expanded,cmd,tip,case,timestamp,uniqueid)
VALUES ;
("F",ALLTRIM(functions.name),"{funcmenu2}",ALLTRIM(functions.parameters),"M",DATETIME(),SYS(2015))
SELECT functions
ENDSCAN
Loading...