AnsweredAssumed Answered

vrf DirectInput (USB joystick) for VEE

Question asked by VRFuser on Oct 21, 2004
> I know almost nothing about VEE but I'm a halfway-capable VB developer.

Good. VEE is very easy to learn and use and you'll probably have no problem
using it except for the fact that VEE is pretty much all "iconic". But it's
often not easy to go from VEE to VB.

> If not, could someone translate my VB sample code into a VEE project?

I can help. I use VB quit a bit. Your best bet is to start by pasting chunks
of your VB code into Formula Objects (grab the lower right corner and drag
it to expand). Terminate each line with a semicolon like C. For a start,
chunks can be individual functions or subs. Local variables can be defined
by adding output pins to the formula object (right click the object, select
"Add Terminal...->Output or hold the cursor over a selected object on the
right side and press Ctrl-A). Double click terminal and name it your
variable name. You can also constrain type using the name dialog, which I
personally think is a really good idea though in general VEE programmers
don't bother).

Now, the differences. The formula object supports a VBA-like script
language, but it doesn't support several very important VB things:

  o If/Then/Else - no ifes. These have to be implemented with a VEE
    If/Then/Else object or a Matlab Script object. I haven't used
    much Matlab scripting myself, though others have.

  o For Each In/Next - no feins either. This one is a real bummer
    if collections don't support indexing by integer. I'm not
    familiar with DirectX, so you're on your own there

  o COM - no direct COM at all. Being a scripting language,
    everything in a formula box that goes through COM has to go
    over IDispatch.

  o Loops are very different. There's no do, while, for/next and
    soforth as such, but there are Until Break (infinite do or
    while), For Count (0 base For/Next with To only) and For
    Range (For/Next with From and Step as well as To). The Next
    object is the Next statement and the Break object terminates
    the enclosing loop, much like Exit.

There are more, but those are the major ones. There are also similarities:

  o Event handlers are defined just about the same way for
    ActiveX objects. For instance, a WINSOCK control called
    sock. It's DataArrival event is caught with a function
    called sock_DataArrival. Create event handlers by right
    clicking the object and selecting Create Event Handler...

  o VEE has an Object Browser, though it's quite different
    from VB's.

  o VEE can handle Variants well. See the Variant topic in help.

  o Any VEE intrinsic function can be called in-line in a
    Formula box.

  o VEE supports a triadic construct (Iif) that looks a lot
    like a C triadic: "(boolean ? True : False)". The parens
    are required.

  o VEE supports a Choose-like construct with it's "To" object.
    (menu I/O->To-> [string is usually very helpful]). I/O
    Transaction is "WRITE CASE". Think Pascal "case of" here.

One thing to keep in mind is that VEE is interpreted. It takes a lot longer
to execute code than compiled VB but this usually isn't a problem. One case
where it is a problem is with loops. In general, loops can kill throughput.
Naturally it depends on just what the loop does, but when iterating lists
also keep in mind that VEE does lists *very* well. Explicit iteration can
usually be avoided with clever VEE expressions.

IMO the biggest obstacle confronting traditional line oriented programmers
is arranging data structures and expressions to take advantage of VEE's list
processing capability. It takes a long, long time

Speaking of data structures, VEE has data type Record which can contain all
intrinsic types (like Type .. End Type) and other Record types as well. One
restriction on nesting user defined types is that arrays (of any dimension)
must be the same size and shape (number of dimensions). Occasionally that's
a killer.

A user type can be declared with a Declare Variable object, though that only
declares one instance of the type. There is the Build Data object which can
be used to collect up several variables into a UDT. The dot operator is
available to perform the same function as in VB and C.

Finally, Define Function can be duplicated (almost) by using the Compiled
Function Interface. If you have to call a dll, you can do it though
sometimes it can be pretty confusing. VEE does not support As Any. It
supports the intrinsic C types short, int, long, float and double. It does
*not* support char, though it does support char* as an alias for Text
(String). Strings are always passed by reference. Arrays are always passed
by reference too. Any CFI type can be splatted to indicate call by reference
or that the passed type is an array.

Bear in mind that a VB Integer is 16-bits wide. I.e. short or Int16 in VEE.
long, Long and Int32 are 32-bits. VEE doesn't have a 64-bit integer, though
Real64 does almost as well.

Forms are a whole different story. VEE calls them Panels. To place a user
interface element on a panel select it and click the "Add to panel" toolbar
button (4th from right) or right click the object and select "Add to panel".
Except for it's contents, a panel object is independent of it's Detail View
representation.

UI is probably where you'll encounter the most frustration (at least it was
for me). There are no text boxes, rather there are String Constants. There
are different kinds of buttons... look at it this way: VEE cooked up it's
own list of UI objects, and usually they don't work like what you're used
to. You'll probably be happier with ActiveX common controls, though that
would be an obstacle to getting things done quickly.

Ok. If you're using VEE 7 you might want to check into using DirectInput via
.NET, though VEE doesn't yet catch .NET events.

Well, that's the gist of it. I could go on all night but there's horror
flicks on.
-SHAWN-


---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

Outcomes