You can use the Class construct, which is even better than a user-defined type, because you can have public/private data members, methods, and constructors/destructors for initializing and releasing objects. Here is an example similar to your VB6 example:
Private Sub Class_Initialize
Set Pins = CreateObject("Scripting.Dictionary")
Public Function GetPins
GetPins = Pins.Keys
Public Function AddPin(sPinName)
Pins(sPinName) = sPinName
When you want to create a variable for a Net_Record, use the "New" statement:
Set netrec = New Net_Record
netrec.Name = "CLOCK"
Many thanks to John for your answer.
Since I did not find anything in Vbscript, about user defined types, I assumed that the
alternative is defining classed.
VB script is not typed. I develop everything in VB6 and have to comment the "AS" before VBS will accept it.
Thanks for your answer.
Although I know very little in Vbscript, I already feel that I prefer to program in Vb6.
In addition, you encouraged me when you wrote that you write everything in Vb.
1. Can I use Vb6 Ide for writing programs, that will be linked to Expedition PCB database?
I hate Vbcsript's attitude of not declaring variable types.
2. In case I can, the product will be an .exe file, I believe.
In this case I will have to run this .exe file form some menu, Stroke or whatever inside Pcb application.
Is this the way? It is just my guess.
I will be glad if you show, in a small example, the steps in order to program with Vb6 instead of Vbscript.
Yes, you can compile VB6 into an exe and have it run. This however will run as an out of prcess script and depending on what you are doing be extremely slow.
For VB6 it would look like this and you can add the reference to the AutoActive Series Type Library
Dim pcbApp As MGCPCB.Application
Dim pcbDoc As MGCPCB.Document
Set pcbApp = GetObject(, "MGCPCB.Application") 'Out of process script has to find the open application
Set pcbDoc = pcbApp.ActiveDocument
For VBscript it would look like this:
Dim pcbApp 'As MGCPCB.Application
Dim pcbDoc 'As MGCPCB.Document
Set pcbApp = Application 'In process can access the Application directly
Set pcbDoc = pcbApp.ActiveDocument
I never publish scripts as .exe files. They are slower, do not work on all platforms and they can be version or machine dependent.
The steps are included in the AATK release. $AATK\help\LABS-Powerpoints\Automation_Lab.ppt and I have included the PPT here.
Automation_Lab.ppt 1.5 MB
I will second what Kendall is saying about VB6. When I first started writing scripts for Expedition, I wrote all of them in VB6. At the time I never knew about the performance hit you got with doing you scripts this way and I just accepted that the scripting engine just wasn't that fast. Then one day (I was probably inspired by Kendall's AATK scripts), I rewrote one of my scripts to be a VBSCRIPT and I was amazed how much faster the scripts ran by running them inside of Expedition vs. externally with VB6.
If you already know VB6, moving to VBSCRIPTs really isn't that much of a change.
Thanks for your explanation and for the presentation file you have sent me.
I followed you instruction, and earlier today I wrote a Vb6 sample program that works fine.
The next programs are going to be mutations of the first one...
Thank you for your answer.
I take into consideration your advices about choosing coding language.
Speed is important but not yet, for me , since my programs in the near future are going to be small.
I prefare to use Vb6 because Vbscript uses a small font, which I hate.
Is there a way to harness another font to Vbscript inside Expedition ?
Another reason: Over the years, I wrote many useful "universal" subs and functions in Vb6.
Is there a way to use them in Vbscript ? ( except by copy-paste).
1) Speed - I did some testing for a presentation I did at U2U in 2006 and I took basically the same code except one was a compiled VB6 program and the other was script ran internally. What the program did was generate a AIS file like you would get when you do File->Export->General Interfaces->Generic AIS, except that it was specially formatted for our needs. The VB6 program took around 10 seconds to run, compared to around a second for the internally ran script. This is a pretty small program. I'm not sure if there is still that much of a performance differential between the two as this was an older version of Expedition.
2) Font Size - which fonts are you talking about? With the editor? Or with the output?
3) I think you will be stuck with copy and pasting unless Kendall has another method.
As far as editting vbscript files, I use an open source program called Notepad++ that works very well for me. I sometimes also use VBSEdit which is probably a bit nicer, but it costs a little bit to register it.
Thanks for your answer. I finally found where to change the font.
I must confess, I did not open AATK yet.
Before jumping into it I nust learn first the basics.
I did not know AATK has also examples to learn from. I thought it is an add_in tool for Expedition Pcb, with additional functions.
Thanks very much.