Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tip of the day. mdot in intellisens
Message
From
26/03/2012 08:56:12
 
 
To
25/03/2012 11:47:28
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01539322
Message ID:
01539353
Views:
73
Walter --

Great stuff!

If you don't mind, I'd like to add this as a tool in Thor, with an addition: variables assigned but not yet added to the
list of LOCALs will appear as well.

This makes this tool of more value for those of us who create our list of LOCAL variables late rather than early.

Jim

>all, I'm not sure whether someone else has posted something similar or even better, but I wanted to share the thing I'm using in my intellisense.
>
>Run the following code in a PRG.
>
>
>USE (_foxCode) SHARED IN 0
>TEXT TO cCode NOSHOW 
>	LPARAMETER oFoxCode
>
>	IF oFoxcode.Location=0	&&Command Window
>		RETURN .F.
>	ENDIF
>
>	lcfxtoollib = SYS(2004)+"FOXTOOLS.FLL"
>	IF !FILE(lcfxtoollib)
>		RETURN .F.
>	ENDIF
>	SET LIBRARY TO (m.lcfxtoollib) ADDITIVE
>
>	lnWinHdl = _WONTOP()
>	_wselect(lnWinHdl)
>
>	DIMENSION laEnv[25]
>	_EdGetEnv(lnWinHdl ,@laEnv)
>	lcStr = _EDGETSTR(lnWinHdl , 0, laEnv[17])
>
>	GetLocDefs(lcStr, oFoxCode)
>
>	IF !EMPTY(oFoxcode.Items[1])
>		oFoxCode.ValueType = "L"
>	ENDIF
>
>	RETURN ""
>
>	*-
>
>	PROCEDURE GetLocDefs(tcStr, toFoxCode)
>		LOCAL lcStr, lnLines, i, lcLine, laLines, lnALen, j, lcWord, lcWords, lnFirstLine, lcInlineParms
>		LOCAL lnPos1, lnPos2, lHasLineContinuation 
>		lcInlineParms = ""
>		
>		IF EMPTY(tcStr)
>			RETURN
>		ENDIF
>		lcStr = tcStr
>		
>		DIMENSION laLines[1]
>		lnLines = ALINES(laLines,lcStr)
>
>		* Quick search backward to find its procedure
>		FOR i = lnLines TO 1 STEP -1
>			lcWord = ALLTRIM(GETWORDNUM(ALLTRIM(laLines[m.i]), 1))
>			IF LEN(lcWord)>3 AND (ATC(lcWord,"PROCEDURE")#0 OR ATC(lcWord,"FUNCTION")#0)
>				* since we are here, let's handle any inline parms
>				lcWord = ALLTRIM(laLines[m.i])
>				IF ATC(REPLICATE("&",2), lcWord)#0   && strip out comments
>					lcWord = ALLTRIM(LEFT(lcWord, ATC(REPLICATE("&",2),lcWord)-1) ) 
>				ENDIF
>				lnPos1 = ATC("(", lcWord)
>				lnPos2 = RATC(")", lcWord)
>				* Check for inline parms
>				IF lnPos1#0 AND lnPos2#0
>					* inline parms
>					lcInlineParms = ALLTRIM(SUBSTRC(lcWord, lnPos1+1, lnPos2 - lnPos1 - 1))
>				ENDIF
>				EXIT
>			ENDIF
>		ENDFOR
>		lnFirstLine = MAX(m.i,1)
>			
>		* Iterate through each line
>		lHasLineContinuation = .F.
>		FOR i = lnFirstLine TO lnLines
>			lcLine = ALLTRIM(laLines[m.i])
>			IF lHasLineContinuation
>				IF LEFT(GETWORDNUM(lcLine,1),1)=","
>					lcLine = SUBSTRC(lcLine,ATC(",",lcLine)+1)
>				ENDIF
>				lcLine = "LOCAL " + lcLine
>			ENDIF
>			lcWord = ALLTRIM(GETWORDNUM(lcLine, 1))
>			
>			* Loop upward until we encounter a PROC or 
>			* FUNCTION call indicating out of scope.
>			IF LEN(lcWord)>3 AND (ATC(lcWord,"PROCEDURE")#0 OR ATC(lcWord,"FUNCTION")#0)
>				* Check for inline parms
>				IF EMPTY(lcInlineParms)
>					LOOP
>				ENDIF
>				lcLine = "LPARAMETERS " + lcInlineParms
>				lcWord = "LPARAMETERS"
>			ENDIF
>
>			* Look only for LOCAL, PUBLIC, PARAM or LPARAM statements
>			IF LEN(lcWord)>3 AND ;
>			  	( ATC(lcWord+" ","LOCAL ")#0 OR ;
>				 ATC(lcWord,"PUBLIC")#0 OR;
>				 ATC(lcWord,"PARAMETERS")#0 OR;
>				 ATC(lcWord,"LPARAMETERS")#0  )
>			ELSE
>				LOOP
>			ENDIF
>
>			lcWords = SUBSTRC(lcLine, ATC(GETWORDNUM(lcLine, 2), lcLine))
>			IF ATC(REPLICATE("&",2), lcWords)#0 AND ATC(REPLICATE("&",2)+',', lcWords)=0   	&& strip out comments, but only when it is not inmediately followed by a comma.
>				lcWords = ALLTRIM(LEFT(lcWords, ATC(REPLICATE("&",2),lcWords)-1) ) 	
>			ENDIF
>			
>			* Have a valid statement so now Iterate through each word (separated by comma)
>			FOR j = 1 to GETWORDCOUNT(lcWords, ",")
>
>				lcWord = GETWORDNUM(lcWords, m.j, ",")
>				
>				* If arrays, then we need to parse out the indexes
>				IF UPPER(GETWORDNUM(lcWord,1)) == "ARRAY"
>					* Skip to second word
>					lcWord = GETWORDNUM(lcWord,2)
>				ENDIF
>
>				lcWord = ALLTRIM(GETWORDNUM(lcWord,1))
>
>				* Parse out any array stuff.
>				DO CASE
>				CASE ATC("[", lcWord)#0
>					lcWord = LEFT(lcWord, ATC("[", lcWord)-1)
>				CASE ATC("(", lcWord)#0
>					lcWord = LEFT(lcWord, ATC("(", lcWord)-1)
>				CASE ATC("]", lcWord)#0 OR ATC(")",lcWord)#0
>					LOOP
>				CASE ATC(";", lcWord)#0
>					lcWord = LEFT(lcWord,  ATC(";", lcWord)-1)
>					IF EMPTY(lcWord)
>						LOOP
>					ENDIF
>				ENDCASE
>				
>				IF Not (lcWord == 'm'  OR lcWord == '_Fool_Intellisense')
>					lnALen = ALEN(toFoxCode.Items,1)
>					IF !EMPTY(toFoxCode.Items[1])
>						DIMENSION toFoxCode.Items[lnALen+1,2]
>						lnALen = ALEN(toFoxCode.Items,1)
>					ENDIF
>					toFoxCode.Items[lnALen, 1] = lcWord	
>				ENDIF
>			ENDFOR
>			* Check for line continuation
>			lHasLineContinuation = (RIGHT(lcWords,1) = ";")
>		ENDFOR
>	ENDPROC
>ENDTEXT
>
>INSERT INTO (_foxcode) (TYPE, Abbrev, cmd, Data, Save, TimeStamp) VALUES("T","mdot","{mdot}","",.T.,DATETIME())
>INSERT INTO (_foxcode) (TYPE, Abbrev, Data, Save, TimeStamp) VALUES("S","mdot",cCode,.T.,DATETIME())
>
>
>
>This is to register the mdot script in intellisense. This will enable you to use the m. and invoke intellisense by declaring the m variable as local
>
>
>LOCAL m as mdot
>
>
>From here on you can type m. and it will list all your locally defined variables
>
>Walter,
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform