Thursday, October 20, 2005

[VBScript] Shell and Heap Sorts

The final versions of the Shell sort and Heap sort classes. First the ShellSorter:
and then the HeapSorter


By the way, I'm unemployed again. Things might be a bit quiet around here for a while.

Saturday, October 15, 2005

[VBScript] sorting algorithms

Thanks to Dr Hans Werner Lang for his helpful comments on the sorting routines, as below:
Hi,
but there is no need to rewrite the outer loop, is it?
    for i=h to n-1
    ...

The inner loop, with the problem of the conditional And, could be written as
    do while j>=h
        if a(j-h)<=t then exit do
        ...
    loop

In my opinion, exit do should be avoided (when possible).

Regards
H.W. Lang
I've made the changes to the class as suggested but haven't posted them as yet.

[MetaCard] Starter Kit script size limit, Part 2

And if anyone was curious what happened to the MetaCard script size issue, Ken Ray said,
>I've been told, via the MetaCard list, that you have a technique for
>getting around the script size limit in MetaCard. If that's so, please
>can you tell me whence I can download the whitepaper about it.

Sorry to disappoint you, Bruce, but I don't. In fact, given that DreamCard is only $99, it seems counterproductive to attempt to get around the script size limits when you can pick up a full development environment very inexpensively.
and Geoff Canyon said
I don't recall that I wrote anything in particular. I did write an exporter for the documentation for earlier versions of Revolution, and they had a small section on dealing with the script limits in the starter kit. The basic point is to understand how to write tight code. You can insert scripts in front and back, and "start using" stacks, and use nested groups to your advantage. You can also store scripts in custom properties and use the "do" command on them.

If you ask on the mailing list, there are several people there who spent significant time working within the script limits who can probably help you with any specific issues. I bought a license early on so I don't have much practical experience.

Finally, if you're concerned about whether Rev is a good fit for what you want to do, ask on the list. People will tell you the truth. There are (many) things Rev is very good for, and (almost as many) things it isn't well suited for.
>I'm told that, sometime late last century, you wrote
>something about side-stepping the script size limit in
>the MetaCard unregistered version.
So the upshot of all this is: spend some money and stop complaining.

Thursday, October 13, 2005

[xbScript] Hooley Dooley! Move over VBScript, here comes xbScript

This is just amazing! "xbScript.dll enables xBase scripting (exactly like MS vbScript and JScript) in any MS ActiveScript compliant Host." Now I can help a friend, who has a large legacy Clipper app running in DOS under Windows, to integrate his software into the Windows environment. And he won't have to learn another language when he wants to tweak things. Hallelujah!!

[EOC] T minus 2 and counting

It's Thurday. I'm busily updating the documentation.

Friday 14 October is "The Last Day". (I wish it was THE last day, that is, the day Jesus returns.)

Of the 19 agencies I've written to, 4 have replied to say they're working on it. Looks like it's back to getting suited up and walking from agency to agency in the Perth CBD saying, "G'day, remember me? Yeah, I'm actually 3D and have feelings."

There's this disease one can get -- I get it often -- called PLOM disease: Poor Little Old Me.

Wednesday, October 12, 2005

[VBScript] Please, please, no more sorting!!

After so many tries, I had thought I was done with it. Well the virtual memory limit on my machine still stands so when the shellSort encountered an array of 1.5 million records, it failed. I could have gone ahead with getting the VM size increased but decided it was better to deal with the limitation as it stood. Who knows, the next bloke may not have much virtual memory either (though, I suppose, he's more likely to have lots more.)

I handed the job over to SORT.EXE and used the Exec method to call it. Like this:
The actual call to SortFile is what were talking about but the oSamples stuff needs some explaining. SuperContainer is a class based on the ADODB.Streams object. Interestingly I had a lot of trouble with the ReadFromFile method in ADODB.Stream. I think this had to do with it expecting Unicode but getting ASCII. When you hand a Unicode file over to SORT.EXE, it sorts it okay but changes it into ASCII. ReadFromFile tries to interpret the file as Unicode and you end up with a mess. Thus the GetFile()/Split/For Each thing in my ReadFile method.

The code for the sorting routine is:
I have a global in my stdFunctions.vbs called bDebugging. It's normally False but I can change it and get some useful feedback thereby.

The upshot of all this is that the sorting seems to be working ... but still not perfectly -- when I gave SORT.EXE a 63 Gigabyte file it didn't like it. But the likelihood of generating datasets that large is low.


[VBScript] read and write local and remote files

Check out a wonderful write up by Antonin Foller of PSTRUH Software on reading and writing files in VBScript. Note the very helpful stuff on Binary Files.

[General] Mergesort

This is a great site for algorithms, like Mergesort. A round of applause for the author, Prof. Dr. H. W. Lang.

It's mostly German language, but there are some English translations and the Java code is fairly human-language-neutral.

Tuesday, October 11, 2005

[VScript] At last, a working shell sort

Finally found a shell sort that works. The problems I had previously might have been had because of this: I converted that straight to VBScript and kept crashing because a[j-h] with a negative index would get evaluated. By using a do/loop and breaking the test up into two parts ... I got stuff to work. Here's the code. Usage is similar to that for heap sort.

[VBScript] Arrrghh!! Sorting out sorting ...

Just when I thought my problems were all over ... or at least the sorting ones ... I found that my machine didn't have enough virtual memory to handle the sort using ADODB (and I don't have the privilege level to do anything about it).

So I ported a heap sort to VBScript and ... so far ... everything look like it's going to work.

Here's the code
... and to use it, something like this ...

[VBScript] Sorting ... another way

I have tried and tried to get Shell sorts working but every algorithm I've tried ends up crashing out with negative indexes into the array.

So below is another way around the whole issue: create a RecordSet, populate it with fields, add data to it and use the RecordSet's own internal sorting routines.
And a trivial example of its use

Monday, October 10, 2005

[VBScript] Synthetic Includes in Traditional VBScript Files

Most of us are aware of the entry "Synthetic Includes in Traditional VBScript Files" in the Rube Goldberg Memorial Scripting Page.

Today I stumbled across how to embed test routines in the include file without causing these routines to be activated when the file is included.

My include file is called "StdFunctions.vbs". At the bottom of the file I've put
When StdFunctions.vbs is included by a script, ScriptFullName evaluates to the name of that script. It's only when StdFunctions.vbs is run by itself that ScriptFullName ends with "StdFunctions.vbs".

BaseName is one of my routines and look a bit like this:
[later that same day]

Read the manual, Bruce, read the manual: why use Basename with .ScriptFullName when you can just use .ScriptName?

[EOC] Other things it could mean

MeaningContributor
Elongated Orbital CrocodileBruce Axtens
Emu-Olive CrossDaniel Axtens
Extra Old CodgerRobert Glanville, Icon Recruitment

Friday, October 07, 2005

[EOC] End of Contract

I've got one more week and then I'm unemployed again.

I feel down. I wish there was something "cutting edge" I could do. Everything I can think of is diametrically opposed to the cutting edge, being either the blunt bit at the back of the knife or the even blunter bit on top of the chisel handle.

Who cares about MetaCard? Who cares about S*BOL but a few diehard fanatics (who are mostly older and greyer than me)? Who cares about Clipper or xHarbour but a few South Americans into retro memorabilia? As for VBScript, this is just one of thousands of websites and I'm a relative newcomer to a tool that's been around for very long time.

Eventually I'll have posted all my MoonRock BASIC, Fitted Software Tools Modula-2, Turbo Pascal 5 and Euphoria code. Whooptie do. Even if I finish my CCNA, learn Haskell, and write Kiwi CatTools equivalents ... who cares?

[MetaCard and Tcl] Blogs.mc

I got asked to describe the stack a little better. Here goes:
My blogs.mc stack has two text fields (fSource and fGenerated) and some buttons at the bottom (create_card, first, prev, next, last, render, preview, delete).

With some marked-up text in the fSource field, I click 'render' and the output of the Tcl script (HTML) is put into the fGenerated field (line 6 of the 'Render' script).

Then when I click on 'preview' the HTML in the fGenerated field gets dumped to a file and passed to Safari. The fGenerated field is modifiable so I can play with things to get what I want and then tweak the Tcl script appropriately afterwards.
About the same time I posted this to the MetaCard list:
On my blog, codeaholic.blogspot.com, I've posted an item about MetaCard (on OS X) using Tcl to more-or-less bypass the script size limit of the unregistered version of MetaCard.
Richard Gaskin wrote back, saying (in part):
since there is no MetaCard anymore anyway, and since Rev only offers a 30-day trial for the engine, I'm not sure how helpful the article will be.

At $99 for the low-end Rev license, is the pricing really so prohibitive?
Also Alejandro Tejada wrote
i do not see how this could get around the 10 lines limit, but Geoff Canyon wrote an extensive tutorial to manage longer scripts within the 10 lines limits.

This tutorial is still useful for developers that want to run longer scripts in their standalone applications.

I get it from Ken Ray's website within the RR v 1.1 docs (saved as a pdf file). i'm not sure if this tutorial is still available in any website.

You could ask directly to Geoff Canyon. Look for his website: inspiredlogic.com
I answered with
> i do not see how this could get around the
> 10 lines limit,

bad choice of words on my part. It doesn't so much get around it as it does acquiesce to the fact and try to use other tools to do what can't otherwise be done. Instead of using MetaCard's HTML mechanism or writin8g something in MetaTalk, I've farmed out the functionality to a Tcl script.

> but Geoff Canyon wrote an
> extensive tutorial to manage longer scripts
> within the 10 lines limits.

of this I was unaware. I have thought about doing something similar. What I usually end up doing however, when I need to hang more closely to MetaCard is to use AppleScript and 'do script' or 'evaluate' the things I need. I will nevertheless make enquiries now that I know better.

Wednesday, October 05, 2005

[General] Five year from now, Google will dwarf Microsoft

Networking Pipeline | Blog | Will Google Buy AOL?

[General] Neuronstorm website update

I'm supposed to be one of the admins for Neuronstorm and when I successfully extract the digit, I'm to implement the Neuronstorm OSI (operating system interface) in GTk for Windows (and possibly Mac OS X).

Daniel's a good developer and there's certainly a fair bit of interest at his school in an open-source version of Inspiration™.

Monday, October 03, 2005

[Clipper 5.3 / xHarbour] .DBF to .CH (Clipper Header)

The client had Clipper 5.3. I had xHarbour. The client had a database of constants. I turned them into a .ch (Clipper Header) file with this bit of code which compiled both under xHarbour and Clipper 5.

[VBScript] 99 bottles of beer - "class" version

Check out my 99 bottles of beer submission.

Look at the entries for your own favourite language. Some of them a dead boring. Submit an example that would show off the real power of the language.

If you're using a language that isn't on the board, submit a version of the song in that too.