Setting up a dll
Moderators: Dorian (MJT support), JRL
Setting up a dll
The dll that I am using has changed and I can not get it to work with MS. MS crashes at the libfunc>
==========
Let>lib=I:\My Documents\pdftestjan\PDFtext.dll
Let>pdffile=I:\My Documents\pdftestjan\NoAscii.pdf
//Call GetPDFText, passing the pdffile and putting result on clipboard
LibFunc>lib,GetPDFText,r,pdffile,2,
//Get text from the clipboard
If>r="9"
messagemodal>"no text"
endif
==========
Here is the function details from the vendor:
function with the type of values and the meaning:
-------------------------------------------------
GetPDFText (FileName: PChar; opt: LongInt; target: PChar; xlspaces: LongInt): PChar
opt=1 means extract the text-content of example.pdf to _example.pdf.txt (in the same directory).
opt=2 means extract the text-content of a pdf-file to the clipboard.
opt=3 means extract the text-content of a pdf-file as a returning text-string.
With a filled "target" you can use a special directory/file.
xlspaces means 1 to delete leading spaces on each text-line or 0 (don't do it).
Kinds of returned (error) codes:
--------------------------------
9001 = File not found
9002 = No pdf-file
9005 = Target isn't valid
1 = For option 1 and 2 ... means it's okay
9 = For option 1 and 2 ... means there's no text (perhaps only images)
Option 3 returns the whole text-string.
-----------------------------------------------------
I have assumed that the error codes are text.
I have written to the software writer and he has replied that I have to change the coding because he has increased the functionality. I can not see what has to change.
==========
Let>lib=I:\My Documents\pdftestjan\PDFtext.dll
Let>pdffile=I:\My Documents\pdftestjan\NoAscii.pdf
//Call GetPDFText, passing the pdffile and putting result on clipboard
LibFunc>lib,GetPDFText,r,pdffile,2,
//Get text from the clipboard
If>r="9"
messagemodal>"no text"
endif
==========
Here is the function details from the vendor:
function with the type of values and the meaning:
-------------------------------------------------
GetPDFText (FileName: PChar; opt: LongInt; target: PChar; xlspaces: LongInt): PChar
opt=1 means extract the text-content of example.pdf to _example.pdf.txt (in the same directory).
opt=2 means extract the text-content of a pdf-file to the clipboard.
opt=3 means extract the text-content of a pdf-file as a returning text-string.
With a filled "target" you can use a special directory/file.
xlspaces means 1 to delete leading spaces on each text-line or 0 (don't do it).
Kinds of returned (error) codes:
--------------------------------
9001 = File not found
9002 = No pdf-file
9005 = Target isn't valid
1 = For option 1 and 2 ... means it's okay
9 = For option 1 and 2 ... means there's no text (perhaps only images)
Option 3 returns the whole text-string.
-----------------------------------------------------
I have assumed that the error codes are text.
I have written to the software writer and he has replied that I have to change the coding because he has increased the functionality. I can not see what has to change.
Robin
- Marcus Tettmar
- Site Admin
- Posts: 7393
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
He's just added an extra parameter: xlspaces
So you need an extra value in the LibFunc line.
LibFunc>lib,GetPDFText,r,pdffile,2,,0
xlspaces can be 0 or 1. I've put 0 in above.
So you need an extra value in the LibFunc line.
LibFunc>lib,GetPDFText,r,pdffile,2,,0
xlspaces can be 0 or 1. I've put 0 in above.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
That worked thanks.
I am trying to get the error code and thought I would find it in
the variable r. The content of r turned out to be a much bigger number = 43980788. Not what I expected at all. So I assume I have the wrong variable.
Can you adjust the libfunc> so as to give me the error code?
I am trying to get the error code and thought I would find it in
the variable r. The content of r turned out to be a much bigger number = 43980788. Not what I expected at all. So I assume I have the wrong variable.
Can you adjust the libfunc> so as to give me the error code?
Robin
- Marcus Tettmar
- Site Admin
- Posts: 7393
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
r is the result of the function being called. However, as previously explained, LibFunc expects an integer value. But this particular function returns a string. Therefore you will not be able to retrieve the return code. That is why you are using option 2 which puts the data on the clipboard - you cannot use option 3 which returns the text. You will get no meaningful return value with either method.
The only solution would be a custom DLL which wraps this one. I believe we did in fact provide you with such a custom DLL. Unless you can get the developer of this particular DLL to make a different version for you which returns an integer instead of a pchar.
DLL functions that return a string are rather non-standard. Look at all the Windows API functions which allow you to get string values. What they do is that a buffer pchar parameter is set to the string and the function returns the number characters set.
The DLL you have is asking for trouble since a pchar is really a reference to a memory location containing the string and the calling program needs to know how many characters to extract from that memory location. This particular DLL is returning a pchar but nothing to say how long the string is!
The only solution would be a custom DLL which wraps this one. I believe we did in fact provide you with such a custom DLL. Unless you can get the developer of this particular DLL to make a different version for you which returns an integer instead of a pchar.
DLL functions that return a string are rather non-standard. Look at all the Windows API functions which allow you to get string values. What they do is that a buffer pchar parameter is set to the string and the function returns the number characters set.
The DLL you have is asking for trouble since a pchar is really a reference to a memory location containing the string and the calling program needs to know how many characters to extract from that memory location. This particular DLL is returning a pchar but nothing to say how long the string is!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
What muddled me was the reference to opt: longInt.
GetPDFText (FileName: PChar; opt: LongInt; target: PChar; xlspaces: LongInt): PChar
I now think that the option is something to control the dll's output and that the error code goes into target. Assuming that is correct I can now understand why I can not use the target as an error code.
I asked the author to produce a new version because his earlier one could not handle the large file I was processing. He added on the extra error codes but they are of no use with MS.
GetPDFText (FileName: PChar; opt: LongInt; target: PChar; xlspaces: LongInt): PChar
I now think that the option is something to control the dll's output and that the error code goes into target. Assuming that is correct I can now understand why I can not use the target as an error code.
I asked the author to produce a new version because his earlier one could not handle the large file I was processing. He added on the extra error codes but they are of no use with MS.
Robin
- Marcus Tettmar
- Site Admin
- Posts: 7393
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Yes, option is the option that controls the output. No, the error code is the function's RETURN value as indicated by the PChar at the END of the function definition.Robbyn wrote:What muddled me was the reference to opt: longInt.
GetPDFText (FileName: PChar; opt: LongInt; target: PChar; xlspaces: LongInt): PChar
I now think that the option is something to control the dll's output and that the error code goes into target. Assuming that is correct I can now understand why I can not use the target as an error code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7393
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
What do you mean by "loading of the file into memory"?Robbyn wrote:I have gone back the loading of the file into memory. I have just tried it and it did not work well.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
That is my way of saying sending the results to the scratchpad.What do you mean by "loading of the file into memory"?
As I am dealing with a file of over 2megs I thought I had better also try saving the output to a file. That has not worked and has caused MS to freeze. This is what I did for the file output:
Let>tempfile=i:\temp\pdftext.txt
LibFunc>lib,GetPDFText,r,pdffile,1,tempfile,0
Thank you very much for your patience in dealing with me over this. I do appreciate your help.
Robin
- Marcus Tettmar
- Site Admin
- Posts: 7393
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
It might be crashing because the function returns a string but Macro Scheduler expects an integer! You are not comparing like with like. The DLL as it stands is not 100% compatible with Macro Scheduler. That has been explained a number of times already.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?