************************************************************************************* FUNCTION UpdateLocalDeclaration( tnHandle, tnSelStart, taLines, tnLine, tcVarName ) ************************************************************************************* LOCAL lcPreFix, lcStr, lcSuffix, lnLen, lnPos, lnTmpPos if .T. and .F. *-- Just to trick projectManager dimension taLines[1] endif *** Get the position where we need to insert the variable *-- DD changed on 09.02.02 *=====================================* * Breaking line with ";" ? * * if so, get the position * * in front of that and the last "," * *=====================================* lcPreFix = ", " lcSuffix = "" if at(";", taLines[tnLine]) # 0 lnTmpPos = rat(",", taLines[ tnLine ])-1 *=================================* * OK, just in case someone does * * something like this * * LOCAL ; * * var1, var2... * *=================================* if lnTmpPos <= 0 lnTmpPos = rat(";", taLines[ tnLine ])-1 lcPreFix = "" lcSuffix = ", " endif else && at(";", ...) lnTmpPos = len( taLines[ tnLine ] ) endif && at(";", ...) lnPos = _EdGetLPos( tnHandle, tnLine - 1 ) + lnTmpPos _EdSetPos( tnHandle, lnPos ) *** Go ahead and update the local declaration *-- DD changed on 09.02.02 *lcStr = ', ' + tcVarName lcStr = lcPreFix + tcVarName + lcSuffix lnLen = LEN( lcStr ) _EdInsert( tnHandle, lcStr, lnLen ) WAIT WINDOW 'Local Declaration Inserted' NOWAIT *** And reposition the cursor lnPos = tnSelStart + lnLen _EdSetPos( tnHandle, lnPos ) *-- DD changed on 09.02.02 *-- and show it _EdStoPos( tnHandle, lnPos, .T. ) ENDFUNCI did not want to go into all that reposition stuff in order to place the cursor at the end of the command. So this was the easiest way to do it.