<@ OMT>-------------------------- |
|
<@ LETVARLIT>string|\n</@> |
<@ OMT>two characters, \ and n</@> |
<@ LETVARLIT>string|Jon 'Maddog' Orwant</@> |
<@ OMT>literal single quotes</@> |
<@ OMT>-------------------------- |
|
<@ LETVARLIT>string| |
<@ OMT>a "newline" character</@> |
<@ LETVARKEY>string|__Newline</@> |
<@ OMT>a "newline" character</@> |
<@ LETVARLIT>string|Jon "Maddog" Orwant</@> |
<@ OMT>literal double quotes</@> |
<@ LETVAREXPLIT>string|Jon &pipe;Maddog&pipe; Orwant</@> |
<@ OMT>Because | and <@ and </@ are significant there are ways to quote them</@> |
<@ LETVARLIT>Bruce Goose|布魯斯鵝</@> |
<@ OMT>a variable name containing spaces. |
<@ OMT>-------------------------- |
|
<@ OMT>Multi-line strings. |
|
<@ LETVARLIT>a| |
|
<@ LETVARLIT>string|This is a multiline string |
|
<@ OMT>-------------------------- |
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.
Saturday, December 12, 2009
[Protium] PLEAC 1.0
[Protium] PLEAC in Protium
For the next few postings I am going to do a PLEAC for Protium. You won't find Protium on PLEAC's pages because PLEAC is limited to open-source languages. Protium is proprietary and closed-source (at present.)
The challenge with converting from Perl to Protium is similar to that faced by linguists translating from one human language to another: do you translate the sense of the utterance, or do you just translate word for word. For example, the Tok Pisin word rabisman literally means "rubbish man". However, it is almost never used that way. Instead it often carries the sense of "fool" or "good-for-nothing." So when converting the Perl to Protium, I've tried to give the sense of the Perl, rather than follow it line for line or word for word.
There will be the odd non-PLEAC posting, but I will try to work my way through the entire PLEAC, all 300K's worth.
Wednesday, October 14, 2009
[Jabaco] JaCOB and WScript.Network
I wonder about myself sometimes. Am I sane? For instance, I’ve taken recently to learning and developing with Jabaco. This would seem from one angle, good, and from another, daft.
Jabaco is a simple programming language with a Visual Basic like syntax. Jabaco enables you to create powerful software for all Java supported operating systems.
So there you have it: a VB6-alike (more or less) syntax targeting the JVM. In my experience, people bagging VB syntax are in the majority. People bagging Java aren’t infrequent either. And I know Java about as well as I know Babylonia Cuneiform.
That said, it’s been a bit of fun figuring things out in Jabaco, and discovering just how effectively one can hook into the Java subsystem.
The code below demonstrates The JACOB Project: A JAva-COM Bridge talking to WScript.Network. Comments are a bit sparse, but VB folk should be able to figure it out quick enough.
Public Sub main(ByJava args() As String) Dim myArgs() As String myArgs = args Dim oShell As ActiveXComponent
'ActiveXComponent is exported by JACOB and referenced in the IDE
'(yes, there’s an IDE, and it’s pretty good too) Set oShell = New ActiveXComponent("WScript.Network") Dim a As String Dim b As String Dim c As String Dim dShell As Dispatch
'Dispatch also part of JACOB. Nice that it uses the standard jargon Set dShell = oShell.getObject() a = Dispatch.call(dShell,"UserDomain") b = Dispatch.call(dShell,"ComputerName") c = Dispatch.call(dShell,"UserName") MsgBox (a & ", " & b & ", " & c) comthread.Release() End Sub
The IDE makes possible ‘compiling’ to an EXE. The code above compiles to about 400K. Of course, the presence of a JRE is implied. And it runs, nicely.
I think I’ll be spending more time with Jabaco. It’s got a lot of promise, especially for the VB-deranged like me.
© Copyright Bruce M. Axtens, 2009.
Thursday, July 02, 2009
[VB6] Using VBScript's Escape and UnEscape
Escape
and Unescape
functions available to the VB6 programmer.The best thing would be add
MSSCRIPT.OCX
to the project, but for the sake of demonstration, I'll use CreateObject
instead.Using the code is easy.
It's that simple. And the technique can be used to get at other VBScript functionality. In fact,
.Language
can have values other than "VBScript"
, making it possible to interface to any language with a Windows Scripting Host presence. © Copyright Bruce M. Axtens, 2009
Tuesday, May 19, 2009
[VB6] MAXDOUBLE, MINDOUBLE, +INFINITY, -INFINITY and NaN
Anyway, I came up with a way of storing these values into Doubles so that they could be used in a Complex Numbers library I've been writing.
Essentially, I create an 8 byte array, load it up with the relevant values, and then, using API calls and the VarPtr function, store the contents of the array into the storage used by the Double.
Here's the code. First the declarations.
Then the routine that does the work.
Finally, a slice out of the Complex Numbers project demonstrating the use of some of these declarations.
Enjoy!
© Copyright Bruce M. Axtens, 2009
Thursday, May 14, 2009
[VB6]Searching an ActiveX/COM object for a method
"After Googling around not quite finding what I wanted, I remembered the Edanmo site which got me thinking about TLBINF32.DLL, downloading Microsoft's TLBINF32.CHM and reading up on GetMembersWithSubStringEx.
Below is the implementation of it (done in VB6 with a reference to TLBINF32.DLL), some demo VBScript and output, and the wrapping of that functionality in some VBA.
VBScript demo. The above code was included in my StdLib DLL in the Registry coclass.
Output from the demo (script was run in SciTE).
Finally, the VBA code. A cell has a symbol in it and this routine finds it or returns an error string. (
reg.
in this case refers to the Registry coclass in the StdLib.DLL)Hmm ... no error checking. Should fix that.
© Copyright Bruce M. Axtens, 2009
Sunday, April 12, 2009
[newLISP] restart-router
The following is a newLISP implementation of a project attempted in VB6. The VB6 one failed to work consistently. The newLISP one hasn't failed yet.
The situation is that our ADSL connection goes down at random times, necessitating a walk down the hall to the comms room, wherein one turns off the power to the router so that it resets. I found out during the week that if I telnet into the router, give the appropriate password and the enter 'restart', that'll restart the router. Will it reduce the need to walk to the comms room? I really don't know as, all of a sudden, the router is working fine.
Here's the code:I really like the fourth parameter on the net-receive call; not only do I receive but I can look for something in what is received. I suppose testing for not receiving it would be good, but I'll leave that for another time.
Once the restart command is sent, there's no need to attempt a net-receive. Just close the connection. Note also the easy way of referring to and using a function in a DLL.
Using the link.lsp script (which comes in the standard newLISP install) I've been able to turn this code into a standalone EXE, and once I've established that it really does do the job, I'll install it on a couple of other machines in the office.
I suppose we actually need the exercise, but maybe we don't need the aggravation.
By the way, my last newLISP posting has generated an interesting conversation on comp.lang.misc (also mirrored on comp.lang.lisp).
© Copyright Bruce M. Axtens, 2009
Thursday, April 09, 2009
[newLISP] reverse-find
Below is my first (ever) lambda expression, a port of the VBScript RevInstr() function.
I must say I'm impressed with newLISP. Note that the minus (-) function above can receive more than one argument. A lot of the functions are like that.
Using the reverse-find is very like the (find) function, as below
One thing that differentiates my lambda expression from the in-built find, is in the manner in which an error is flagged.
I'm not sure at this point why the difference and what to do about it. In my use of (find) I check for a result equal to nil, but with (reverse-find) I have to check to see if the result is a string. For example,
Doubtless, someone in the newLISP Fan Club will set me straight soon.
© Copyright Bruce M. Axtens, 2009