Quote: "Quote: "I would like to create an external plugin to emulate the 'Option Explicit' during compile time.
"
I thought about that too, but to have it active as you type (again similar VB IDE)
"
Why? In VB IDE (VB6) the check are made only during compile time. I think it's better because I often use a variable while I'm writing a piece of code, then I declare it.
I made another upgrade. I have rewritten the codelist autocompletion routine. It's a medium change, so it's not easy to publish.
With my changes codelist are populated with keywords, functions and variables, also keywords that have between some space chars. When you select a keyword in codelist, entire keyword under cursor are replaced and not only one word.
There are 3 possibilities to populate codelist: all possible keywords, selected the keyword that better matches old selection (this is the method that i prefer), only keywords that start with the same old selection, old method with all keyword that contain the old selection. To choose, you have to modify 3 lines in frmMain.code_CodeList (there are some comment).
I hope this is understandable.
First, I've added a declaration in frmMain:
Dim CodeListColEnd As Integer
immediately under the same declaration for CodeListColStart.
Then I've replaced frmMain.code_CodeList (sorry but there are a lot of changes, too difficult to report all changes).
Private Function code_CodeList(ByVal Control As CodeSenseCtl.ICodeSense, ByVal ListCtrl As CodeSenseCtl.ICodeList) As Boolean
Dim i As Integer
Dim wsKeys As String
Dim wsLine As String
Dim wsToken As String
Dim wiStartToken As Integer
Dim wiEndToken As Integer
Dim wbFlg As Boolean
wsKeys = KeywordsString
For i = 0 To UBound(functions)
If functions(i).name <> "" Then
wsKeys = wsKeys & "|" & functions(i).name & vbCrLf
End If
Next i
For i = 0 To UBound(vars)
If vars(i).name <> "" Then
wsKeys = wsKeys & "|" & vars(i).name & vbCrLf
End If
Next i
'Get start position so we can delete the text when the user makes a choice
Dim r As CodeSenseCtl.Range
Set r = code.GetSel(False)
' CodeListColStart = r.StartColNo - Len(code.CurrentWord)
i = r.StartColNo + 1
wiStartToken = -1
wsToken = ""
wsLine = " " & code.GetLine(r.StartLineNo)
wbFlg = True
Do While i >= 1 And wbFlg = True
Do While (IsValidIdentChar("", Asc(Mid$(wsLine, i, 1))) = 1) And i > 1
i = i - 1
Loop
wbFlg = (InStr(1, UCase$(wsKeys), UCase$(Mid$(wsLine, i + 1, r.StartColNo - i + 1))) > 0)
If (InStr(1, UCase$(wsKeys), "|" & UCase$(Mid$(wsLine, i + 1, r.StartColNo - i + 1))) > 0) And UCase$(Mid$(wsLine, i + 1, r.StartColNo - i + 1)) <> "" Then
wiStartToken = i + 1
End If
i = i - 1
Loop
If wiStartToken >= 0 Then
i = r.StartColNo + 1
wiEndToken = i
wbFlg = True
Do While i <= Len(wsLine) And wbFlg = True
If (InStr(1, UCase$(wsKeys), "|" & UCase$(Mid$(wsLine, wiStartToken, i - wiStartToken + 1))) > 0) Then
wiEndToken = i
End If
i = i + 1
Loop
wiStartToken = wiStartToken - 1
wiEndToken = wiEndToken - 1
Else
wiStartToken = r.StartColNo
wiEndToken = r.StartColNo
End If
wsLine = Mid$(wsLine, 2)
CodeListColStart = wiStartToken - 1
CodeListColEnd = wiEndToken
Set ActiveCodeListCtrl = ListCtrl
'Popup list to help user with function names
Dim StartLetter As String
Rem StartLetter = UCase(code.CurrentWord)
StartLetter = UCase$(Mid$(wsLine, wiStartToken, wiEndToken - wiStartToken + 1))
'Add DBP functions
For i = 0 To UBound(Keywords)
'##If Keywords(i).name <> "" And UCase(Mid(Keywords(i).name, 1, Len(StartLetter))) = StartLetter Then
'If you want the old method, use this line
' If Keywords(i).name <> "" And InStr(1, UCase(Keywords(i).name), StartLetter) > 0 Then
'If you want only keywords that start with selection, use this line
' If Keywords(i).name <> "" And Left$(UCase(Keywords(i).name), Len(StartLetter)) = StartLetter Then
'If you want all keyword, use this line
If Keywords(i).name <> "" Then
If Len(Keywords(i).params) < 30 Then
ListCtrl.AddItem Keywords(i).name + " (" + Keywords(i).params + ")"
Else
ListCtrl.AddItem Keywords(i).name
End If
End If
Next i
'Add user functions
For i = 0 To UBound(functions)
'If you want the old method, use this line
' If functions(i).name <> "" And InStr(1, UCase(functions(i).name), StartLetter) > 0 Then
'If you want only keywords that start with selection, use this line
' If functions(i).name <> "" And Left$(UCase(functions(i).name), Len(StartLetter)) = StartLetter Then
'If you want all keyword, use this line
If functions(i).name <> "" Then
If Len(functions(i).params) < 30 Then
ListCtrl.AddItem functions(i).name + " (" + functions(i).params + ")"
Else
ListCtrl.AddItem functions(i).name
End If
End If
Next i
'Add variables
For i = 0 To UBound(vars)
'If you want the old method, use this line
' If vars(i).name <> "" And InStr(1, UCase(vars(i).name), StartLetter) > 0 Then
'If you want only keywords that start with selection, use this line
' If vars(i).name <> "" And Left$(UCase(vars(i).name), Len(StartLetter)) = StartLetter Then
'If you want all keyword, use this line
If vars(i).name <> "" Then
If Len(vars(i).vtype) < 30 Then
ListCtrl.AddItem vars(i).name + " (" + vars(i).vtype + ")"
Else
ListCtrl.AddItem vars(i).name
End If
End If
Next i
ListCtrl.SortStyle = cmCodeListSortAscending
ListCtrl.SelectedItem = ListCtrl.FindString(StartLetter, True)
CodeListActive = True
code_CodeList = True
End Function
Then, in frmMain.code_CodeListSelMade I've changed only one line:
rdelete.EndColNo = r.EndColNo
changed in
rdelete.EndColNo = CodeListColEnd
Last change, in mcodecense I've added a declaration:
Public KeywordsString As String
and this piece of code immediately before: frmKeywords.Hide
For i = 0 To UBound(Keywords)
If Keywords(i).name <> "" Then
KeywordsString = KeywordsString & "|" & Keywords(i).name & vbCrLf
End If
Next i
That's all (I hope).
Obviously can be a lot of bugs, but I hope no.
PS: Some people with experiences of working with CVS? It could be a good idea, or not?