VB6 Parser/Lexer/Scripter - scripting

I've got a game in VB6 and it works great and all, but I have been toying with the idea of creating a scripting engine. Ii'm thinking I'd like VB6 to read in flat text script files for me and then lex/parse/execute them.
I have good programming experience, and I've built a simple C compiler, as well as a LOGO emulator before.
My question is:
Are there any tools that I can use, like Lexx/Yakk/Bison to help me? How should I approach this problem in regards to lexing, parsing, and feeding the commands back to VB6 so I can handle them? Is this idea a BAD IDEA in the sense that there are too many obstacles in the way (For example, building minesweeper in assembly, though not impossible, is very difficult, and a bad idea.)?

Use the Microsoft® Windows® Script Control because it is easy to integrate into existing VB6 applications. The control supports VBScript, JScript, or any other "Active Script" implementation.
I have used the Windows Script Control in four projects and it works extremely well. Very easy to integrate. I wish Microsoft would have given us a replacement in .NET, and made it as easy to use. (I understand the control is not needed in .NET, but having the ability to simply create an object that handles everything is nice.)
Windows Script Control
The Microsoft® Windows® Script Control
is an ActiveX® control that provides
developers with an easy way to make
their applications scriptable. This,
in turn, enables users to extend
application functionality through
scripts, much as they do with macros
today.
INFO: Where to Obtain the Script Control at http://support.microsoft.com/kb/184739. Includes links to other howto support articles.
Chapter 13: Adding Scripting Support to Your Application at http://msdn.microsoft.com/en-us/library/aa227413(VS.60).aspx
Designing a Calculator at http://msdn.microsoft.com/en-us/library/aa227421(VS.60).aspx
How To Use Script Control Modules and Procedures Collections, Inserted from http://support.microsoft.com/kb/184745
How To Use the AddObject Method of the Script Control, Inserted from http://support.microsoft.com/kb/185697
SAMPLE: SCRIPTEX.EXE Uses the ScriptControl with Visual Basic, Inserted from http://support.microsoft.com/kb/189484
Windows Script Control can be downloaded at http://www.microsoft.com/downloads/details.aspx?familyid=d7e31492-2595-49e6-8c02-1426fec693ac&displaylang=en. (Supported Operating Systems: Windows 2000; Windows 98 Second Edition; Windows ME; Windows NT; Windows Server 2003; Windows XP)
MSDN Search of "MSScriptControl.ScriptControlClass" at http://social.msdn.microsoft.com/Search/en-US?query=%22MSScriptControl.ScriptControlClass%22&ac=8
MSDN Search of "Windows Script Control" at http://social.msdn.microsoft.com/Search/en-US?query=%22Windows+Script+Control%22&ac=8
MSDN Search of "MSSCRIPT" at http://social.msdn.microsoft.com/Search/en-US?query=MSSCRIPT&ac=8

Unless you're doing it for your own instruction, you may want to try using Lua: VB6 - Lua Integration

If you're willing to use VBScript rather than VB6 you might be able to just use the MSScriptControl to run the commands rather than creating your own. Here's an article discussing using it from a .Net app, though it's an ActiveX control so should give you quite a bit of flexibility.
The control can be downloaded from here.

I've actually seen some quite reasonable implementations of compilers/interpreters in VB6[1] - It's not the language I would choose (few functional features, insufficent static type system), but with experience, you can outweigh these drawbacks and be quite productive - So why not.
You can use the GOLD parser generator that supports VB6 as a start.
[1]: Somewhere on PSC or in this download repository I think ...
Note that there is the MSScriptControl too.

There also appears to be an additonal alternative for VB6:
SadScript is an variant of VB6 most prominently used for VB6 as an scripting engine in MMORPGS .
See here for more : What is sadscript? Can I use it in vb.net? Why hasn't anyone I have asked heard of it?

Related

Unmanaged language or library to write shell extension?

I need to write a cascading shell extension à la 7Zip. It appears that only the .Net 4 framework supports this, but even in March 2012, MS still advises against using a managed language for this purpose.
So what unmanaged languages are available to write shell extensions for Windows (XP, Vista, 7)?
I read that writing a COM DLL is not easy even for seasoned C++ developpers, so it's probably a dead-end for non-pros. VB6 has been deadware for a decade. I looked at PureBasic and PowerBasic but they don't seem good candidates either.
So is there simply no reasonably easy language to write a cascading shell extension?
As a work-around, is there a library that I could call from VB.Net that would handle the hard part?
Thank you.
There is not a lot you can do if you're not willing to go into the unmanaged world. There is a series of articles on codeproject. This is the first of such articles. They helped me quite a bit. It is written in unmanaged c++ using visual studios ATL project which takes care of some other classes that you would otherwise have to deal with.
COM objects may not be the easiest thing to understand but once they're working they are fairly solid. If anything just treat it as a learning experience.

What VB or VBA interpreters or compilers are available for the Windows operating system?

I am looking for an interpreter (compiler would work too) for Visual Basic or VBA. I am not looking for any kind of UI support. Basically, I have a series of somewhat complex VBA modules which make no reference to any external DLLs and make no use of any user interfaces. Is there any such tool available short of having Microsoft Office or Microsoft Visual Basic for the Windows operating system?
VBA only exists as an embedded "macro language" inside a host application like Excel. At one time you could even buy the SDK to embed VBA in your own applications, but there was never any "stand alone VBA."
VBScript is close to VBA and VB in syntax and semantics, but it also requires a host. Common desktop hosts include WSH, MSHTA, and the Vista/Win7 "gadget" framework. That's probably your best bet if it meets your needs.
It is remotely possible to do what you want using VB5CCE (Control Creation Edition) if you can find it. This was free, but could not compile to EXEs. It might have worked as an interpreter however by running it with the /run switch. I'm not certain of that though.
There are 3rd party freebies as well such as Jabaco which uses a very VB/VBA-like syntax.
Update: VB5CCE does not support the /run switch.
This might be worth a peek if VB.NET is a fit. Visual Studio Express ... I'm not sure what the free version leaves out though.
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express

Does Mono support visual basic (not .NET)?

Someone asked me today if it was possible to port a visual basic application to Linux or similar platform, I assumed it was .NET so I suggested to use Mono, but noticed that on their vb support page they only talk about vb 8 (.NET)
Does mono support non-.NET vb? In fact I'm not sure what he is using, I think vb6, I'm not sure of the versioning at all though.
No, VB6 is an entirely different beast from VB.NET. Mono is basically there to run (via JITting, interpreting or AOT-compiling) IL - the Intermediate Language that VB.NET and C# compile down to. (Of course it also provides the libraries and compilers.)
Running VB6 requires an entirely different execution environment, basically.
No, but you could take a look at gambas
Gambas is a free development
environment based on a Basic
interpreter with object extensions, a
bit like Visual Basic™

Active X Development: VC++ or VB or Other technologies

We are in the process of creating active-x controls used within our application.
Since Microsoft stopped supporting classic Visual Basic, is it wise to use Visual Basic to develop the Active X control or the latest VC++/ATL/MFC libraries provide more feature where we can create controls faster by leaving Visual Basic flexibility?
We will not be able to use .NET/VB.NET/C# since the application is supposed to work inside containers and containers may not support latest .NET runtime.
Any other language is best fit for Active X control development other than VB and VC++?
I, personally, would recommend using Delphi for this. It is still actively developed, and has the control you get with C++, but a rapid development environment more like VB.NET.
#nobugz: If you are really interested what is ActiveX in Delphi, look at docwiki. Normally it is 100% source code (yours + VCL, VCL is also available as sources) with autogenerated COM wrappers. So all potential security problems are also in source code. If you find a security problem in VCL, please send a bug report to Quality Central.
Here is a good example on how to create ActiveX Controls with C# .NET
http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx
By all means VB6 is the best language. After reading your question I feel that you are a VB6 developer. If you know VB6 and use it then why hesitate using it for producing ActiveX controls.
I program in Delphi as well as VB6 along with VB.NET and C# but creating ActiveX controls is the easiest in VB6 compares to all other development tools.
If you are hell bent on not using VB and if you are looking for an alternative then try out PowerBasic (commercial - very costly) or PureBasic (commercial but affordable) Get it from here or better still MinGW (a GNU C++ compiler).
I have to say that VB6 with a good book like Developing COM/ActiveX Components with VB6: A Guide to the Perplexed you will be up and running faster.

An alternative IDE for Sybase Powerbuilder

Does anyone know of an alternative IDE for Sybase Powerbuilder? It feels pretty clunky, after working with VS2008 and Eclipse.
If not, has anyone successfully worked with this language outside the IDE? I'm not against using a simple text editor, but I find edit-import-regenerate-test-export-edit is clunkier than simply using the Powerbuilder editor.
To date, the only tools I have had any success with are:
PowerGen, for builds (with NUnit and CruiseControl.NET)
ConTEXT, which has syntax highlighting for Powerbuilder
PBL Peeper, which has some interesting features not present in the IDE
EDIT: I added a bounty to draw some wider attention to the question. It would be a very nice thing to have, if it exists.
EDIT: Well that was disappointing. The bounty apparently did not cause even 1 new person to look at the question.
None that I'm aware of, although you could probably use a source control tool, edit in your source control repository, and Get Latest Version from the PB IDE to shorten your text editor cycle. Be warned that there are hacks required to edit anything over 128 ASCII. (My guess is that this is to allow everything Unicode to be source controlled in the most restrictive source control tools.)
As Paul said, PB12 is coming with based on the Visual Studio shell, and will include things like collapsible code blocks, Intellisense, etc.... However, for PB12, this will only be used for WPF targets and a few .NET-type targets (like assemblies), last I heard. Win32 targets will continue to use the "classic" IDE.
Good luck,
Terry.
P.S. Thanks for the PBL Peeper compliment.
The PowerBuilder IDE is clunky, but I don't think developing completely outside the PowerBuilder IDE is a good idea. I think there are just too many dependencies right now.
However, the IDE for PowerBuilder 12 will be built using Microsoft's Visual Studio Isolated Shell so it ought to be much better when that is released. Also, I believe they'll be doing away with the PBL format which ought to make source control much easier to work with.
Certainly something to watch.
What I do is right-click the object and edit source. Then I copy the text and paste it into Notepad++ to edit. I copy and paste back to PowerBuilder, then I can save and see any errors. I've got a fairly decent User Defined Language for PowerScript if anyone's interested.
Added:
Please be aware that I've seen the PB Source editor corrupt DataWindows. They were all large DataWindows. To be safe always export DataWindows to edit.
One tool that will most probably make your PB experience way better is Visual Expert, which provides a good source browser. Such a tool should have been integrated into the PB IDE a long time ago, IMHO. Only problem is that it's not free, as opposed to the other tools you mention.
Regarding using external source editors, you can probably take advantage of OrcaScript, which is a scripting language that lets you perform actions such as export and import of PB objects from outside of the IDE. It will require some effort, but you can setup a basic dev env using batch files with ORCA scripts and some additional external tools. However, this setup will lack any visual editing capabilities, which means no (feasible) GUI or DW work. If you're mostly into NVOs, it could work. But then if that's the case, why use PB in the first place?...
I too have heard PB12's use of VS will be limited to some .NET stuff, which will probably benefit only a very small portion of the PB programmers community. I'm afraid the rest of us are stuck with the awful IDE for years to come.
Other than exporting the source and editing it I don't know of another IDE for PB. One problem you may have is that the exported source contains a lot of syntax that is not documented in the manuals. The PB IDE generates this code but there is no support for creating it by hand. I think you are stuck with the PB IDE
In my modest five Years of experiences starting with Powerbuilder 5/6, now using PB 10, I tempt to :
build my own browser from the classdefinition object based on Powerbuilder
tried to use autohotkey in order to open datawindows comfortable (we have several thousands in the project and i am two-finger-driven)
truly investigated in the idea using an external editor/IDE suppoted by an autohotkey script which is undermined by sybase allowing only mouse-click-usage of PB
using Visual Expert which is neither a truly integration in the IDE, nor is really worth in analyzing datwindow/powerscript interaction
ending by build hopes on PB12 Visual Studio, which lacks - depending on compatibility issues - ...
... i came to the conclusion that there will be no chance in improving Powerbuilder to an state-of-the-art language
In my philosophy - I obtained during those years - I distinguish between two types of OOP-oriented languages:
the one that award using object-orientation like C#, Python, Ruby (C++) etc. and very much the Java-Eclipse/Netbeans-Universe does
the other one that punish using object-orientation like Powerbuilder and the old Visual Basic, for example (which is causative the OOP-Idea comes afterwards and is "plugged in").
Especially the demand that all object should always be compiled (regenerated) and that you could't work with ancestors and descandants concurrently makes it painful to use real OOP.
...In memory of the good old Unix(Solaris)/C++ days...
I was researching a replacement solution that would be similar to PowerBuilder and I came across two that caught my eye.
The first was 'React Studio' https://reactstudio.com/ which I found via Alternativeto.net .
And the second was from an ad at the top of some Google searches but it was similar enough and looked good enough at first glance for me to want to take a closer look at it, and it's called 'Servoy' https://servoy.com/ .
Still researching but I currently have React Studio at the top of our list.
The TextPad editor has a syntax definition file for PowerBuilder 6.x contributed by anr#aon.at that I downloaded for free and customized several years ago. It works fine for later versions (including 8), doing keyword color highlighting on PowerScript srx files. Editing large source files in PB could get it to crash so it's usually safer, faster and more convenient to export to srx file, edit outside the IDE then re-import.