Question Parsing/Interpreting a small defined set of user commands

tim8w

Active member
Joined
Oct 26, 2010
Messages
38
Programming Experience
5-10
Not sure really how to explain what I'm looking for help on. But here goes:

I have a small set of commands that I want to let my user select and then I will create a function to implement it. For instance, in our software, we have three main loops. One for the Channel being tested, One for Temperature and one for Pressure. We also have a few commands that we would like to expose.

Here is my proposed list of Keywords:
CHANNEL_LOOP
TEMP_LOOP
PRESSURE_LOOP
NEXT_CHANNEL
NEXT_TEMP
NEXT_PRESSURE
SET_TEMP
SET_PRESSURE
DELAY
COMPARE

So now I will create a small User-Defined function using these keywords:

CHANNEL_LOOP
TEMP_LOOP
SET_TEMP
PRESSURE_LOOP
SET_PRESSURE
DELAY
MEASURE
COMPARE
NEXT_PRESSURE
NEXT_TEMP
NEXT_CHANNEL

After reading this list, somehow I need to convert it to VB.Net code that looks something like this:

For iChannel = 1 to Number OfChannels
For Each Temperature In TemperatureList
SetTemperature(Temperature)
For Each Pressure In PressureList
SetPressure(Pressure)
PressureDelay
Value = ReadValueFromChannel
CompareToTolerances(Value)
Next Pressure
Next Temperature
Next iChannel

I would love to convert this on the fly as the User-Defined function is read in, if possible.

Any ideas?

Thanks,
Tim
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,345
Location
Sydney, Australia
Programming Experience
10+
Are you saying that you want a developer to be able to type one of those keywords into the VB code editor and have it replaced with the corresponding code? If so, look into "code snippets" That term has a specific meaning in VS. You can write your own code snippets and have them work much as the builtin ones do. I haven't created my own for a long time but you may find the following VS extension helpful:

 
Top Bottom