Actually the whole thing is a bizarre mix of Cygwin, Win2k CMD and Euphoria. When I get some more time I'll go into the issue a little more deeply. Here's the line that the title refers to:
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.
Monday, August 29, 2005
Thursday, August 25, 2005
[VBScript/HTA] Broggle on Steroids
Big changes to Broggle.hta. No more #code/#endcode etc. Just #text, #code, #quot and #end. Now the HTA is more in line with the MetaCard and Tcl version at home on the iBook. I've also put in a preview button (which should probably be somewhere other than where it is right now) which puts the conversion results into a <DIV> at the bottom (thus the scrollbar at the side.)
Enjoy
Enjoy
[VBScript] Classes in VBScript, the definitive article?
Article Information | |
---|---|
Article Title: | 4GuysFromRolla.com - Using Classes within VBScript |
Article Author: | Mark Lidstone |
Published Date: | Thursday, September 23, 1999 |
Article URL: | http://www.4GuysFromRolla.com/webtech/092399-1.shtml |
Labels:
4GuysFromRolla,
class,
VBScript
[VBScript] Changes to existing stuff
Just a couple of changes. To the Container class I've added
and I forgot to include the DQuote for PArray
public sub Clear redim vat(0) itemCount = 0 end sub
and I forgot to include the DQuote for PArray
Function DQuote( aText ) DQuote = Chr( 34 ) & aText & Chr( 34 ) End Function
[VBScript] Arrays within arrays and debugging them
Array() can contain Array(). I do it lots. But there's the issue of debugging things and of knowing what's in an array full of embedded arrays.
So I wrote PArray(). Tcl has a function of the same name which does the same thing. And the output looks very like an Euphoria sequence (now there's a nice language) but you can change that if you want to.
I suppose the next thing to do is to write a compiler of PArray() decompilations that would allow me to write nested arrays out to a text file and then read them back in. One day.
So I wrote PArray(). Tcl has a function of the same name which does the same thing. And the output looks very like an Euphoria sequence (now there's a nice language) but you can change that if you want to.
I suppose the next thing to do is to write a compiler of PArray() decompilations that would allow me to write nested arrays out to a text file and then read them back in. One day.
Labels:
Array,
Parray,
ShowStructure,
Tcl,
VBScript
[VBScript] My first class
A "Container" class, which I can add stuff to and then pull it all out nicely Join()-ed or else as a raw array.
And the nice thing is I can have multiple collections rather than the single instance thing I had a couple of days ago. Some test code ran like this:
Monday, August 22, 2005
Template changes
Right, now we have black code instead of that faded out look. I think I'm finally starting to get the hang of CSS.
Good news about Modula-2 on Mac OS X
Hooray! Finally I get to leverage all my Modula-2 skill into the Mac OS X environment. Bring on the Objective Modula-2!!
Objective Modula-2 and An Overview of Objective Modula-2 by the founder of the project, Benjamin Kowarsch.
http://en.wikipedia.org/wiki/Objective_Modula-2
See also Objective Modula-2 – A Discussion and Working Paper
Labels:
Mac OS X,
Modula-2,
Objective Modula-2
Friday, August 19, 2005
Leftovers after a meal of Bruce the Goose
I had a blog. It was called "Bruce the Goose" (aka Virtual Unknowns) and it listed programming languages and tried unsuccessfully to keep up with them all. The names of all that I found are in the links list on the left. If you find any dead links or want to suggest additions or changes, please contact me.
Thursday, August 18, 2005
Broggle - a blogging tool in an HTML application
Okay, now a quick shift from straight VBScript to VBScript inside an HTML application. It's to deal with formatting issues I have with Blogger. The solution is probably way simpler than this.
Saved as Broggle.hta and then double-click launched in Explorer.
Just put "#code" and "#endcode" around code and "#text" and "#endtext" around text, click on [Evaluate], then click on [Copy to Clipboard], and then paste into the blog.
Saved as Broggle.hta and then double-click launched in Explorer.
Just put "#code" and "#endcode" around code and "#text" and "#endtext" around text, click on [Evaluate], then click on [Copy to Clipboard], and then paste into the blog.
How I used the CalculateState function
It's awful, and I'm glad I don't have to follow this any further. By the way, if you see any routines you would like to see elucidated, please let me know.
Labels:
ADO,
state tables,
VBScript
Toward a state table generator (VBScript)
This bit of code I used to create a two-state table for 5 variables. It would have been fairly easy to add more states -- by changing the if to a select case in 'state' and giving the for loops more things to loop through -- and to add more variables -- by specifying another loop and and another call to 'state'.
I won't be writing the generator ... the whole need for state tables disappeared in a meeting earlier today.
I won't be writing the generator ... the whole need for state tables disappeared in a meeting earlier today.
Labels:
state tables,
VBScript
Wednesday, August 17, 2005
Once I wrote a global search and replace ...
... and now I find that a simple bit of unix command line replaces hundreds of lines of MoonRock BASIC.
$ for x in *.chk; do cat $x | sed -e s/Database=/Filename=/ > tmp; mv tmp $x; done
Get every file ending in .chk, pipe it through sed to change the relevant string, capture the result into a temporary file and then copy it over the original.
$ for x in *.chk; do cat $x | sed -e s/Database=/Filename=/ > tmp; mv tmp $x; done
Get every file ending in .chk, pipe it through sed to change the relevant string, capture the result into a temporary file and then copy it over the original.
Labels:
cygwin,
MoonRock BASIC,
search and replace,
sed
Found another use for Eval() in VBScript - state tables
Imagine trying to keep track of all possible combinations of four variables. Big if/then/else/end if, right? Not necessarily.
Labels:
Eval,
state tables,
VBScript
Tuesday, August 16, 2005
Cygwin again - Oh how I love the unix command line
$ getclip | gawk '{ print "convert.vbs /profile:" $1 ".cvt\ndaily.vbs /profile:" $1 ".dly\n" }' | putclip
It gets the word I put in the clipboard (selected and copied out of SciTe) and puts back on the clipboard the word as commands and filenames to be pasted back in. For example, I put
Marble_Bar
on the clipboard, reissue the command, and get
convert.vbs /profile:Marble_Bar.cvt
daily.vbs /profile:Marble_Bar.dly
It gets the word I put in the clipboard (selected and copied out of SciTe) and puts back on the clipboard the word as commands and filenames to be pasted back in. For example, I put
Marble_Bar
on the clipboard, reissue the command, and get
convert.vbs /profile:Marble_Bar.cvt
daily.vbs /profile:Marble_Bar.dly
Labels:
command generator,
cygwin,
gawk,
getclip
HTA - HTML applications
I've played with this one from time to time and would like sometime to take it a bit further. It's a text editor written as an HTML application, good for doing CScript and WScript.
Simple VBScript Development Tool
It's also good an example of what you can do with HTML applications, especially the idea of being able to put a functional interactive GUI front end over VBScript (and JScript).
Simple VBScript Development Tool
It's also good an example of what you can do with HTML applications, especially the idea of being able to put a functional interactive GUI front end over VBScript (and JScript).
Labels:
HTA,
HTML Applications,
VBScript
Monday, August 15, 2005
A printf for VBScript - derivative work
Uwe Keim, on the CodeProject site, has a "printf"-ish VBScript function. Here's my version (which I now realise is almost word for word the same as someone else's take on Uwe's original.) So ...
Sven Axelsson, on the above site, has a version of Uwe's original, called "FormatMessage-like formatting in VBScript" which looks almost exactly like that below (except he calls his "Fmt", rather than "Subst").
Sven Axelsson, on the above site, has a version of Uwe's original, called "FormatMessage-like formatting in VBScript" which looks almost exactly like that below (except he calls his "Fmt", rather than "Subst").
function Subst(str, args) dim res dim i res = str for i = 0 to UBound(args) res = Replace(res, "%" & CStr(i+1) & "%" , args(i) ) next res = Replace(res, "\n", vbCrLf) res = Replace(res, "\t", vbTab) Subst = res end functionAnd an example of use:
theSelector = "SELECT * FROM %1% WHERE [aKey] >= (DATESERIAL(%2%, %3%, %4% ) + TIMESERIAL( %5%, 0, 0 )) AND [aKey] <= (DATESERIAL(%2%, %3%, %4% ) + TIMESERIAL( %5%, 59, 59 ))" theSelect = Subst( theSelector, Array( theTable, theYear, theMonth, theDay, theHour ) )
Thursday, August 11, 2005
Synthetic include in VBScript
On the Rube Goldberg Memorial Scripting Page there's a synthetic include for VBScript which I use for everything. Thus the "StdFunctions.vbs" of the previous post.
Labels:
Synthetic Include,
VBScript
Cygwin, bash, grep, gawk, tclsh, VBScript
What a combination!!
I've found Cygwin enormously helpful. Take the following snippet for example, which extracts the names of all the Subs and Functions from my library file into a file, and then hands that file on to a tcl script.
#!/bin/bash grep -i '^Function ' StdFunctions.vbs >func.lst grep -i '^Sub ' StdFunctions.vbs >> func.lst cat func.lst | gawk -F " " '{ print $2 }' | gawk -F "(" '{ print $1 }' > Routines.lst rm func.lst tclsh routines.tclThe output file, Routines.lst, looks like this (partially)
CreateMDB OpenDatabase OpenDatabase2 SelectSheet GetColumnDownToEnd GetColumnDownToLimit RangeToArray VectorToTwoDimArray RelativeToAbsolute MakeKey3 MakeKey4 TimeStamp Zerofill IsFile IsINISection GetINIStringRoutines.tcl takes this, and an internally specified list of files to check (which I could have coded so as to specify on the commandline) and then tells me whether any of these routines are referred to in the list of files.
#!/bin/tclsh set mm 0 proc searchFile {theFile theString} { #puts "Searching $theFile for $theString" set h [open $theFile r] set d [split [read $h] \n] close $h set c 0 set m 0 foreach dline $d { incr c if {[string match -nocase "*${theString}*" $dline] == 1} then { set m 1 #puts "$theFile $c: $dline" } } return $m } set vlist [list Create.vbs Daily.vbs NewBatchPrepare.vbs convert.vbs] set h [open Routines.lst r] set flist [split [read $h] \n] close $h foreach fitem $flist { if { $fitem == "" } { continue } set mm 0 foreach vfile $vlist { if { $vfile == "" } { continue } #puts "To search for $fitem in $vfile" set r [searchFile $vfile $fitem] if {$r == 0} { #puts "No sign of $fitem in $vfile" } set mm [expr {$mm + $r}] } if { $mm < 1 } { puts "No sign at all of $fitem" } }It's not foolproof. Some routines are used internally by StdFunctions.vbs. But it's helpful.
Data is Code, Code is Data -- VBScript
Interesting ...
wscript.echo eval( "dateserial( " & _
eval( "join( array( 1996,12,10 ), "","")" ) & _
")" )
I think I can do this in Tcl too. Now to find a use for it ...
Wednesday, August 10, 2005
The Mexican IF in VBScript
The trouble with an IIF, at least in VBScript, is that
both the true and the false get evaluated on
invocation:
I gave up in the end, but it was fun ... sort of.
Function IIF( theCond, theTrue, theFalse )
Dim theResult
If theCond Then
theResult = theTrue
Else
theResult = theFalse
End If
IIF = theResult
End Function
So I tried delaying evaluation:
Function EIF( theValue, theTest, theTrue, theFalse )
Dim theResult
Dim theBool
theTest = Replace( theTest, "$1", "theValue" )
theTrue = Replace( theTrue, "$1", "theValue" )
theFalse = Replace( theFalse, "$1", "theValue"
)
theBool = Eval( theTest )
If theBool = True Then
theResult = Eval( theTrue )
Else
theResult = Eval( theFalse )
End If
EIF = theResult
End Function
Calling it was to work like this,
i = 1
j = EIF(i,"$1=1","$1", "$1*$1")
That is, if i = 1 then j = i else j = i * i. If I'd just used IIF it would have been
i = 1
j = IIF(i=1,i,i*i)
and the true and false parts would have been evaluated
before invocation of the IIF function.I gave up in the end, but it was fun ... sort of.
Tuesday, August 09, 2005
Binary Clock - SNOBOL4
I didn't want to have something ordinary as the first post. So we do SNOBOL4. Other implementations of this algorithm can be found on the Snobol4 Wiki.
Labels:
binary clock,
SNOBOL4
What do you do with 20 year's worth of code?
I can't throw it all away, so I'm putting it up here for all to see. Mostly gravel ... the odd gem. Might be good for something or someone, even as an example how not to do something.
Subscribe to:
Posts (Atom)