[plt-scheme] Anyone competent in VB? MzCom & Excel question.

From: ifconfig (nslookupifconfig at hotmail.com)
Date: Sat Mar 27 16:37:35 EST 2004

this is what you want:

Private Function Slashify(Str As String)
    Slashify = Replace(Str, "\", "\\"
End Function

Quite simple, isn't it?

ifconfig
BAGOS
http://bagos.sourceforge.net


----- Original Message ----- 
From: "Roderick McGuire" <mcguire at telerama.com>
To: <plt-scheme at list.cs.brown.edu>
Sent: Saturday, March 27, 2004 12:36 AM
Subject: [plt-scheme] Anyone competent in VB? MzCom & Excel question.


>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> I'm interacting with MzCom from MS Excel via Visual Basic. While I can 
> write some VB I'm not really competent. Non the less, most things seem 
> to be working. The code I've included below can also be found in the 
> spreadsheet:
> 
> http://pong.telerama.com/~mcguire/PLT/MzCom.xls
> 
> The one problem I'm having is that I don't seem to be able to catch 
> SchemeError events. Being able to would really help in debugging. I 
> think this is the right way to do it but the code below is never
> invoked.
> 
> Private Sub MzCom_SchemeError(s As String)
>      MsgBox ("Scheme Error: " + s)
> End Sub
> 
> I noticed that Andre Van Meulebrouck, in his test program (found on this 
> page: http://www.cs.utah.edu/plt/develop/ ) never does anything with the 
> SchemeError event so I don't know if it is even working. Nor am I 
> competent enough in VB to know how to tell.
> 
> My version is Excel 2002 as part of Office 10.
> 
> P.S. Is there some less ugly way to write the "slashify" function below?
> 
> Dim initted As Boolean
> Dim MzCom As New MzObj
> 
> Public Sub MzComREPL()
>      Dim sin, sout As String
>      initialize
>      On Error GoTo 20
>      sin = "'ready"
> 10  sout = MzCom.Eval(sin)
>      sin = InputBox(sout)
>      If Not sin = "" Then GoTo 10
>      Exit Sub
> 20  MsgBox ("repl: " & Err.Number & vbCrLf & Err.Description)
>      initted = False
>   '   Err.Clear
>   End Sub
> 
> Private Sub initialize()
>      On Error GoTo 10
>      If initted = False Then
>          MsgBox ("initting")
>          ' HAVE MzCom load some functions here
>          MzCom.Eval ("(current-directory " + 
> Quote(slashify(ThisWorkbook.Path)) + ")")
>          initted = True
>      End If
>      Exit Sub
> 10  MsgBox ("init: " & Err.Number & vbCrLf & Err.Description)
> End Sub
> 
> Private Sub MzCom_SchemeError(s As String)
>      MsgBox ("Scheme Error: " + s)
> End Sub
> 
> Private Function Quote(s As String) As String
>      Quote = Chr$(34) + s + Chr$(34)
> End Function
> 
> Private Function slashify(s As String) As String
>      Dim sl As Integer
>      sl = Len(s)
>      If sl = 0 Then
>          slashify = ""
>      Else
>          If "\" = Left$(s, 1) Then
>              slashify = "\\" + slashify(Right$(s, sl - 1))
>          Else
>              slashify = Left$(s, 1) + slashify(Right$(s, sl - 1))
>          End If
>      End If
> End Function
> 
> 
> 
> 
> 
> 


Posted on the users mailing list.