Past (20 years or so) and present code. A variety of languages and platforms. Some gems. More gravel. Some useful stuff and some examples of how not to do it.
Wednesday, August 30, 2006
[VBScript] StandardLibrary.zip
As promised in the previous posting, Standard Library is now available as a ZIP. Thanks to Perth Linux Users Group for the storage space.
Labels:
Perth Linux Users Group,
PLUG,
StandardLibrary,
VBScript
Saturday, August 12, 2006
[VBScript] Standard Library
My apologies for the hiatus between entries. I have been struggling with the "black dog."
Recently, I was asked to make the Standard Library available, so here it it. For ease of digestion, I have segmented it, though you will find that some functions make use of routines in other segments. I will in due course make the whole file available in a single ZIP. Until then, you'll have to navigate as best you can.
Cheers, comments, creative criticism and corrections all gratefully received. It's been a few months since I last used the library; you may find the odd rough edge. (I have edited the file a little for publication, but only to remove references to previous employers' sites, and a few redundant comments.)
As knife manufacturers have no way of controlling how people use their knives, so I have no control over where and how you use the code on this weblog. I have tried as much as possible to acknowledge my sources. I would appreciate it if you also would do the same.
Okay, with that out of the way, let's begin.
I have adopted an Hungarian variable naming regime that is a bit different to the usual given in VBScript examples from Microsoft. Objects start with "o", collections with "c", strings with "s", numbers with "n", booleans with "b", dates with "d", arrays with "a", and variants with "v". I must confess, however, that I have not always followed my own standards.
First, a few symbols and standard objects.
First, domain access: GetAvailableNTDomains
CSCRIPT StandardLibrary.vbs
Anything goes in this section, and the stuff below is what was in there the last time I tested the file, which was sometime in January 2006.
I don't know when I'll be doing VBScript again; I have designed the Sudoku solver but haven't coded it yet. I had thought of doing it as an HTA.
At the moment I'm looking into the ISIS database technology (a friend has developed a Win32 Unicode-enabled version), serial i/o, FreeBASIC, and xbScript.
I hope to recommence regular postings soon, likely in support of a new language, Protium. Until then.
© Copyright Bruce M. Axtens, 2006
Recently, I was asked to make the Standard Library available, so here it it. For ease of digestion, I have segmented it, though you will find that some functions make use of routines in other segments. I will in due course make the whole file available in a single ZIP. Until then, you'll have to navigate as best you can.
Cheers, comments, creative criticism and corrections all gratefully received. It's been a few months since I last used the library; you may find the odd rough edge. (I have edited the file a little for publication, but only to remove references to previous employers' sites, and a few redundant comments.)
As knife manufacturers have no way of controlling how people use their knives, so I have no control over where and how you use the code on this weblog. I have tried as much as possible to acknowledge my sources. I would appreciate it if you also would do the same.
Okay, with that out of the way, let's begin.
I have adopted an Hungarian variable naming regime that is a bit different to the usual given in VBScript examples from Microsoft. Objects start with "o", collections with "c", strings with "s", numbers with "n", booleans with "b", dates with "d", arrays with "a", and variants with "v". I must confess, however, that I have not always followed my own standards.
First, a few symbols and standard objects.
Next a symbol table class, similar to that used in CLIVE.
Next, String manipulation tools. There are lots of things in here: LeftOf, RightOf, CountFields, NthField, BeginsWith, EndsWith, Contains, ForceExtension, Subst, Subst2, DQ, Between, Wrap (which puts HTML markup around text), RemoveSpaces, Zerofill2, RightFill, and LeftFill.
The one date manipulation function came out of a problem with encoding dates in Access. See the link for a fuller description.
Arrays: AAdd, InArray, StrInArray, AMax and Amin.
File manipulation code: CollectFiles, ReadFile, ReadFirstLine, Exists, WriteFile, Env and IncludeClass. Essentially wrappers around existing functionality, but with more flavour.
How do you classify the "mexican if"?
Now we get into some serious Active Directory (AD) and Windows Management Interface (WMI) code. As much as possible I've included the relevant attributions for stuff I have lifted and/or adapted.
First, domain access: GetAvailableNTDomains
Then computers: GetRemoteEnvironment, GetOnlineComputers, GetNetView, GetComputers, GetNBT, GetNBTA, GetDomainComputers, GetSpecs, ResolveIP, DetectTempFolder, and ExistsFolder.
Also user-specific tools: GetOUofUser, GetLoginProfiles, GetMac, GetComputerUsers, GetComputerUsers2, GetDomainUser, and GetNameAndDescription.
I didn't use them often, but there are function here for Group access as well: GetComputerGroups and GetGroups.
Okay, now we get onto the application control routines, starting with Excel: ExcelStart, ExcelNewSheet and ExcelColumnNames.
Then, Access routines: CreateDatabase, OpenDatabase, OpenRecordSet, CreateStructure and CreateIndex.
One lonely email-specific tool: ErrorEmail.
Internet Explorer tools: ModalDialog, ModalText, ModalThing, ReadClipboard, WriteClipboard.
An LDAP function: GetDefaultNamingContext
A function, CaptureDOS. It runs a command in the CMD shell, captures the output to a text file, and then sucks the data into a string variable.
Logging variables and functions: LogTo, Log, Die and Faint.
Next comes a testing module which is only executed if the library itself is executed directly. For example:
CSCRIPT StandardLibrary.vbs
Anything goes in this section, and the stuff below is what was in there the last time I tested the file, which was sometime in January 2006.
Okay, that's the end of it.
I don't know when I'll be doing VBScript again; I have designed the Sudoku solver but haven't coded it yet. I had thought of doing it as an HTA.
At the moment I'm looking into the ISIS database technology (a friend has developed a Win32 Unicode-enabled version), serial i/o, FreeBASIC, and xbScript.
I hope to recommence regular postings soon, likely in support of a new language, Protium. Until then.
© Copyright Bruce M. Axtens, 2006
Labels:
StandardLibrary,
VBScript
Subscribe to:
Posts (Atom)