Consider this use case scenario: I wish to auto complete and provide the skeleton for code constructs like for loop and if else statements. How can I go about doing it?
the user writes this line in VBScript,
function add(a,b) and then presses enter, the program should automatically add the line end function after it.
Also I need to handle the case where there are nested statements like in the case of if and endif statements.
Any help would be greatly appreciated.
thanks
In short: Read the line after the pressing of Enter, grab the keywords with some regular expressions, look up the keywords in a dictionary and perform the coupled function (by use of function pointers) that is added as item to that key.
Now you can create a dictionary with keywords as keys and names of functions (as string) to perform with each keyword.
In a separate module, create a collection of functions that are coupled to certain keywords, like generating the text
VbNewLine & "End Function".To keep everything neat, you should place the regular expressions, keywords and functions to perform with that keywords in separate objects like dictionaries or custom created classes. Don’t start with Select Case if you want to go for extensibility.