LPARAMETERS; toFoxScript * note the use of toFoxScript what is the parent of the oFoxcode normaly used * this gives extended access * the PEMs normaly usedin a script are at toFoxScript.oFoxcode * To enable this script, make sure that you have the lAllowCustomDefScripts * custom property set to .T. (you can set this in the IntelliSense Manager). * This script expandes a IF Statement to * IF Statement THEN * * THEN &&Statement * keeps indent *Section needed in all scripts LOCAL; lcFxToolLib AS STRING,; lcLastWord AS STRING,; lnWinHdl AS INTEGER LOCAL lvReturn_On_Error AS VARAINT *this is because VFP 7.0 need other retuirn value for wrong IF VERSION(5)<800 THEN lvReturn_On_Error = '' ELSE &&VERSION(5)<800 lvReturn_On_Error = .F. ENDIF &&VERSION(5)<800 IF toFoxScript.oFoxcode.Location=0 THEN &&toFoxScript.oFoxcode ... &&Command Window RETURN lvReturn_On_Error ENDIF *since all custom scripts in CustomDefaultScripts will be called, we need to check if we are the one to call *this is by MS and need to be changed IF VERSION(5)<800 THEN *this is because VFP 7.0 does not know toFoxScript.cCustomScriptName. VFP 8.0 is generic IF !UPPER(toFoxScript.cCMD)='TH' &&Script = TH RETURN lvReturn_On_Error ENDIF ELSE &&VERSION(5)<800 IF !UPPER(toFoxScript.oFoxcode.UserTyped) == UPPER(toFoxScript.cCustomScriptName) &&Script = TH RETURN .F. ENDIF ENDIF &&VERSION(5)<800 lcFxToolLib = SYS(2004)+"FOXTOOLS.FLL" IF !FILE(lcFxToolLib) RETURN lvReturn_On_Error ENDIF SET LIBRARY TO (m.lcFxToolLib) ADDITIVE */Section needed in all scripts *Custom part LOCAL; lcCompiler AS CHARACTER,; lcLeft AS CHARACTER,; lcFullLine AS CHARACTER,; lcLine AS CHARACTER,; lcMyVa AS CHARACTER,; lnLen AS INTEGER,; lnLeft AS INTEGER,; lnRight AS INTEGER,; lnOr AS INTEGER,; lnAnd AS INTEGER lcFullLine = toFoxScript.oFoxcode.FullLine lcFullLine = LEFT(lcFullLine,LEN(lcFullLine)-LEN(toFoxScript.cCustomScriptName)) lcLine = LTRIM(lcFullLine) lcCompiler = IIF(lcLine='#','#','') lcLeft = STRTRAN(lcFullLine,lcLine,'') lnLeft = AT(' ',lcLine) lnRight = RAT(' ',lcLine) *first 30 signs only. lcLine = SUBSTR(ALLTRIM(SUBSTR(lcLine,lnLeft+1,lnRight-lnLeft-1)),1,30) TEXT TO myvar TEXTMERGE NOSHOW THEN <<lcLeft>> ~ <<lcLeft+lcCompiler>>ENDIF &&<<lcline>> ENDTEXT *Remove last word, only if neede by the script. lcLastWord = ALLTRIM(GETWORDNUM(toFoxScript.oFoxcode.FullLine, GETWORDCOUNT(toFoxScript.oFoxcode.FullLine))) IF VERSION(5)<800 THEN *this is because VFP 7.0 does not know toFoxScript.cCustomScriptName. VFP 8.0 is generic lcLastWord = LEFT(lcLastWord, LEN(lcLastWord) - 2) ELSE &&VERSION(5)<800 lcLastWord = LEFT(lcLastWord, LEN(lcLastWord) - LEN(toFoxScript.cCustomScriptName)) ENDIF &&VERSION(5)<800 toFoxScript.ReplaceWord(lcLastWord) * Handle extra space IF ASC(RIGHT(toFoxScript.oFoxcode.FullLine,1))=32 lnWinHdl = _WONTOP() _EDSETPOS(lnWinHdl, _EDGETPOS(lnWinHdl) - 1) ENDIF *Returnvalue toFoxScript.oFoxcode.ValueType = "V" RETURN myvar */Custom part
LOCATE FOR TYPE='Z' AND Abbrev='CustomDefaultScripts '
LOCATE FOR TYPE='Z' AND EMPTY(Abbrev)
* Default script triggered by a space -- used for commands only LPARAMETER oFoxCode LOCAL loFoxCodeLoader, lcLine, lcCmd, lnWords, lcLastCmd, lcTalk LOCAL; lvReturn AS VARIANT IF !FILE(_CODESENSE) RETURN "" ENDIF lcLine = ALLTRIM(oFoxCode.FullLine) lcCmd = UPPER(ALLTRIM(GETWORDNUM(lcLine,1))) lnWords = GETWORDCOUNT(lcLine) lcLastCmd = GETWORDNUM(lcLine,lnWords) IF EMPTY(lcLine) OR LEFT(lcLine,1)="*" OR ; ATC("L", _VFP.EDITOROPTIONS)=0 OR ; UPPER(lcLastCmd)=="AS" RETURN "" ENDIF SET PROCEDURE TO (_CODESENSE) ADDITIVE loFoxCodeLoader = CREATEOBJECT("FoxCodeLoader") lvReturn = loFoxCodeLoader.START(m.oFoxCode) loFoxCodeLoader = NULL IF ATC(_CODESENSE,SET("PROC"))#0 RELEASE PROCEDURE (_CODESENSE) ENDIF *return is Charcter IF VARTYPE(lvReturn)='C' THEN RETURN lvReturn ENDIF &&VARTYPE(lvReturn)='C' RETURN "" DEFINE CLASS FoxCodeLoader AS FoxCodeScript PROCEDURE MAIN() LOCAL; lvReturn AS VARIANT lvReturn = THIS.DefaultScript() RETURN lvReturn ENDPROC ENDDEFINE
IF Test TH
IF Test THEN ENDIF &&Test