I have been programming in Basic since the early 80s, though I am not a programmer by trade. Scripting is completely new to me, so I need to do some reading, and it is my hope that someone here can point me in the right direction. I will briefly outline what I ultimately need the application to do in the hopes that it will help narrow the reading suggestions.
I am developing a microprocessor based embedded system that will require a highly flexible PC based application interface. Initially I planned on writing a full parser and compiler to allow users to develop assembler-like programs, but quickly realized this approach would be both complex to accomplish and complex for users to learn. In searching for a solution I stumbled across VBScripting.
The embedded system is a data acquisition system that can monitor a wide variety of analog and digital periphials and can operate in several different modes. The VB Application will contain all of the basic interface functions such as wrapping parameters into "Valid Request Packets", "Unwrapping Responses", and "Interface Types and Parameters" (ComPort/ParallelPort/GPIB/USB etc); however, selecting parameters and which functions to access needs to be in the end-user's domain.
What I am specifically interested in reading about with regards to scripting and VB applications is "where to draw the line". That is if I want to create a "general function" like "Acquire ADC Output" and from the embedded system's point-of-view this corresponds to a series of commands like:
"A5 2000 01 03 16" ;Acquire 8192 8 bit Samples From ADC 03 ADC Clock = 1.152Mhz
"50 2000 01 00" ;Read last 8192 Bytes From Buffer1, Release Buffer
This Function's output would be "wrapped" as follows:
"0C A5 2000 01 03 16 50 2000 01 00 00"
and then sent to the embedded processor by the selected interface device (Serial Port/Parallel Port/GPIB/USB).
Should I write this Function in my VB App and then 'call it' from the VB Script, or would it be better to simply create a series of SUBs and FUNCTIONs that are automatically loaded into the VB script control prior to the User's script. In this case the VB app would simply contain the various controls and pass control of them over to the script...
If anyone can point me toward a good reading source or some example code that might help me select the best approach I would be grateful.
Fish
I am developing a microprocessor based embedded system that will require a highly flexible PC based application interface. Initially I planned on writing a full parser and compiler to allow users to develop assembler-like programs, but quickly realized this approach would be both complex to accomplish and complex for users to learn. In searching for a solution I stumbled across VBScripting.
The embedded system is a data acquisition system that can monitor a wide variety of analog and digital periphials and can operate in several different modes. The VB Application will contain all of the basic interface functions such as wrapping parameters into "Valid Request Packets", "Unwrapping Responses", and "Interface Types and Parameters" (ComPort/ParallelPort/GPIB/USB etc); however, selecting parameters and which functions to access needs to be in the end-user's domain.
What I am specifically interested in reading about with regards to scripting and VB applications is "where to draw the line". That is if I want to create a "general function" like "Acquire ADC Output" and from the embedded system's point-of-view this corresponds to a series of commands like:
"A5 2000 01 03 16" ;Acquire 8192 8 bit Samples From ADC 03 ADC Clock = 1.152Mhz
"50 2000 01 00" ;Read last 8192 Bytes From Buffer1, Release Buffer
Code:
The Function might look like this:
Private Function AcquireADC_Samples(ADC as Integer, iBytes as Long, MemBuff as Integer, ClkDivider as Single) as String
Dim Sql as String
Sql = "A5" & HexString(iBytes,4) & HexString(MemBuff, 2) & HexString(ADC,2) & HexString(ClkDivider,2)
Sql = "50" & HexString(iBytes,4) & HexString(MemBuff,2) & "00"
Sql = "0C" & Sql & "00"
Call SendHexString Sql
AcquireADC_Samples = ReadBytes(iBytes)
End Function
This Function's output would be "wrapped" as follows:
"0C A5 2000 01 03 16 50 2000 01 00 00"
and then sent to the embedded processor by the selected interface device (Serial Port/Parallel Port/GPIB/USB).
Should I write this Function in my VB App and then 'call it' from the VB Script, or would it be better to simply create a series of SUBs and FUNCTIONs that are automatically loaded into the VB script control prior to the User's script. In this case the VB app would simply contain the various controls and pass control of them over to the script...
If anyone can point me toward a good reading source or some example code that might help me select the best approach I would be grateful.
Fish