Success! I rolled the declarations back to ByVal for the strings
(I don't know why ByRef didn't work) and then used vbNullString instead of
"" in the PerlEZCreate.
Many thanks for pointing me in the right direction,
Ken!
Allan
-----Original Message-----Hi Allan,
From: Ken Barker [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 29, 2004 6:20 PM
To: Allan Clarke
Subject: RE: PerlEZ and VBA
The documentation reference I gave you also has this note:
Note The vbNullString constant is used when calling external procedures, where the external procedure requires a string whose value is zero. This is not the same thing as a zero-length string ("").
try mhPerl = PerlEzCreate(vbNullString, vbNullString)
Please see the VB help topic "declare statement".
Cheers,
Ken.
At 22:38 28/04/04, you wrote:
Content-class: urn:content-classes:message
Content-Type: multipart/alternative;boundary="----_=_NextPart_001_01C42D1D.BE6C94A8"
Thanks for the observation, Ken. It switched the declarations to ByRef for all string inputs.
The code still fails as before. Any other ideas?
Allan
-----Original Message-----
From: Ken Barker [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 27, 2004 5:55 PM
To: Allan Clarke; [EMAIL PROTECTED]
Subject: Re: PerlEZ and VBA
_______________________________________________
- Hi Allan,
- The MSDN that came with my VB6 has a topic called "Declaring a DLL Procedure" that documents the declare keyword. It seems to indicate that strings should be passed by reference, i.e. try passing the strings byref not byval.
- Cheers,
- Ken.
- At 23:18 27/04/04, Allan Clarke wrote:
- Content-class: urn:content-classes:message
- Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C42C5A.1CAA1988"
- Greetings!
- I want to invoke PerlEZ through VBA and I found a sample wrapper, which I have shown below. When I run the simple Test macro (from Excel), I get the "cannot create perl handle" error from PerlEZCreate(). This is so simple, it must be some kind of configuration issue.
- Anyone have ideas? (XP, AS Perl 5.6.1 build 633)
- Allan
- ------------------------------------------
- Option Explicit
- Const BUFFER_LENGTH As Long = 255
- Private mhPerl As Long
- Private Declare Function PerlEzCreate Lib "PerlEZ" (ByVal lpFileName As String, ByVal lpOptions As String) As Long
- Private Declare Function PerlEzDelete Lib "PerlEZ" (ByVal PerlEzHandle As Long) As Boolean
- Private Declare Function PerlEzEvalString Lib "PerlEZ" (ByVal PerlEzHandle As Long, ByVal CodeString As String, _
- ByVal BufferString As String, ByVal BufferSize As Long) As Long
- Public Function Eval(InString As String) As String
- Dim sBuffer As String * BUFFER_LENGTH
- 'get handle to interpreter
- If mhPerl = 0 Then
- mhPerl = PerlEzCreate("", "")
- If mhPerl = 0 Then
- MsgBox "No handle to Perl", vbExclamation, "Perl EZ Class"
- Exit Function
- End If
- End If
- 'get evaluation of string
- PerlEzEvalString mhPerl, InString, sBuffer, BUFFER_LENGTH
- Eval = sBuffer
- End Function
- Public Function ClosePerl() As Boolean
- Dim blnClosed As Boolean
- If mhPerl <> 0 Then
- blnClosed = PerlEzDelete(mhPerl)
- If blnClosed Then
- mhPerl = 0
- End If
- ClosePerl = blnClosed
- Else
- ClosePerl = True
- End If
- End Function
- ------------------------------------------
- Public Sub test()
- ChDir "c:\perl\bin" ' just to see if its a path problem
- Eval ("1;")
- End Sub
- _______________________________________________
- ActivePerl mailing list
- [EMAIL PROTECTED]
- To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
