Asked — Edited

Scripting In VB

I'm brand new to VB. I went through the first two tutorials and now I'm interested in how to make a control for script commands like a simpler version of the scripting window in ARC. Any help would be appreciated. Thanks!


ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

PRO
Synthiam
#1  

You'd like to have an application where people can enter script commands into it?

Pre-compilers are pretty tough. ARC's scripting engine was a huge job. If your script commands are simple, then you could use regular expression to extract line by line to see what the command is, then parse for the data.

The ARC script parser takes the textual script and turns it into tokens. Each token represents a specific command, then an array of variables. Some of the commands accept a variety number of arguments, so that's variable also.

So what I do is...

  1. I have an enum of textual commands.

  2. I split the entire script by new lines into an array. I do a foreach on each line

  3. Every function needs a ( so I split that line into 2 (index 0 is the command, index 1 are the arguments)

  4. I trim the index 0 (command). Then compare it against the enum list to see if its a known command

  5. Then I split index 1 (arguments) by the comma , because all arguemtns are split by commas

  6. Then I populate a List of an object that contains the arguments and the command

Once that's all done. Now I have a List array of tokenized commands and their arguments

Now I can use that function for Syntax Check and also Execute. For speed, I store the tokenized array list so it doesn't have to be parsed before execution. On syntax check, I also have a String in the tokenized object that contains an error. So when the parsing occures, if there are missing arguments or out of range, then I can populate that error.

I display the errors when the syntax check is done. But not during execution. Because execution requires syntax check :)

In the execute method, I foreach through each token and call the respective methods that execute that function.

Tada!

#2  

I may just use a series of drop down menus since I'm only interested in a few scripts. Something along the lines of select command, select port for command, select variables.

I think I can handle that.

Next, how to implement a "sleep" command. And how to actually execute the commands in order.

#3  

Hi All,

I am brand new to EZ-Robot and anxiously awaiting my EZ-B so I can get started on my project. I am not really big into Visual Studio programming (yet). I am however familiar with vbs scripts. Can a vbs script control EZ-B or is there something else that is needed? Is it possible to execute vbs scripts to do something on the EZ-B? This could be one in the same, but I am not sure...as I have not used Visual Studio...only notepad to create vbs scripts.

Thanks in advance for any assistance on this.

v/r

Kevin

PRO
Synthiam
#4  

You totally could. I don't know exactly how. VBS is a lot more uhm... difficult to use than Visual Basic in Visual Studio.

#5  

This is a really decent tutorial on getting started with VB http://www.homeandlearn.co.uk/net/vbNet.html

I am using it with VB 2008 Professional instead of Express, so some of the lessons need a little interpretation where there are minor differences, but overall, it is pretty good. If you know VBS, you will be able to pick up VB.net pretty easily.

My next challenge is C#. I am coming from VB 6.0 and I have an application for work that I have to do in VB.Net before I start learning C#.

Alan

#6  

Thanks for the replies gents,

That is a good tutorial! Thanks Alan! I am going through it fast and as you said it does appear to be very similar to VBS.

What I am trying to do, which will require some more work with VB.NET and VBS, is to create a VBS that can call the EZ-B dlls. If i can do that and pass variables back and forth in between them, I will be well on my way to integrating my new robot project (which has yet to happen) into my Home Automation system (which uses VBS).

Thanks again!

Kevin