1. newbie questions

Hello,

I'm new to Euphoria and my last programming was some Basic, 15 years ago at
school !
I try to access a dll ( BigSpeedZip.dll, fast zipping/unzipping) but i'm
stupidly stuck there.
The VB declare for the function  i want to use : 
'.....This function opens zip file and creates a list of items, corresponding to
'     contents of zip file. Must be called before any other function to get
access
'     to zip file. ZipName is the path and full name of zip file,
'     for example: 'C:\TEST.ZIP'. Returns zero on success.
Declare Function zOpenZipFile Lib "bszip.dll" (ByVal zipname As String) As Long

And here is a part of my EU 2.3code, win32  :
--
atom bszip
sequence ZipFile
bszip = open_dll("bszip.dll")
ZipFile="c:\\indisp.zip"
OpenZipFile = link_c_func(bszip, "zOpenZipFile",{C_CHAR}, C_INT)
ok = c_func (OpenZipFile, ZipFile)   -- error message here  "C routine
 zOpenZipFile() needs 1 argument, not 13"
-- if i put 13 C_CHAR between the braces, it hangs
-- if instead of ZipFile="c:\\indisp.zip" i write ZipFile
=open("c:\\indisp.zip", "ub") the error is "c_proc/c_func: argument list must be
a sequence ", so what to do ?
puts(1,ok) --end code
Another question : how to get the actual filename from a file number ( eg   
c:\indisp.zip vs 1342177280 ) ?

I take a look at the examples, but it didnt help me that much. Euphoria seems
really nice, so i hope to improve myself a bit...

Thanks, Phil.

new topic     » topic index » view message » categorize

2. Re: newbie questions

Phil,

Just simply change

 ok = c_func (OpenZipFile, ZipFile)

to

ok = c_func (OpenZipFile, {ZipFile})


In the first case, ZipFile is a sequence (in this case a string) which
happens to be composed of thirteen atoms (in this case characters).  The
c_func() function expects a sequence having the parameters to be passed as
the elements.  The way you had it originally, the string is broken into its
13 individual characters, which c_func() attempts to pass as 13 parameters.
Enclosing Zipfile in curly braces makes a sequence with one element
(ZipFile), which c_func() with then pass as the single parameter.

This error is very common--I've done it a hundred times myself.

-- Mike Nelson

new topic     » goto parent     » topic index » view message » categorize

3. Re: newbie questions

>From: praufast at free.fr
>Subject: newbie questions
>
>
>      Hello,
>
>I'm new to Euphoria and my last programming was some Basic, 15 years ago at 
>school !
>I try to access a dll ( BigSpeedZip.dll, fast zipping/unzipping) but i'm 
>stupidly stuck there.
>The VB declare for the function  i want to use :
>'.....This function opens zip file and creates a list of items, 
>corresponding to
>'     contents of zip file. Must be called before any other function to get 
>access
>'     to zip file. ZipName is the path and full name of zip file,
>'     for example: 'C:\TEST.ZIP'. Returns zero on success.
>Declare Function zOpenZipFile Lib "bszip.dll" (ByVal zipname As String) As 
>Long
>
>And here is a part of my EU 2.3code, win32  :
>--
>atom bszip
>sequence ZipFile
>bszip = open_dll("bszip.dll")
>ZipFile="c:\\indisp.zip"
>OpenZipFile = link_c_func(bszip, "zOpenZipFile",{C_CHAR}, C_INT)
>  ok = c_func (OpenZipFile, ZipFile)   -- error message here  "C routine 
>zOpenZipFile() needs 1 argument, not 13"
>-- if i put 13 C_CHAR between the braces, it hangs
>-- if instead of ZipFile="c:\\indisp.zip" i write ZipFile 
>=open("c:\\indisp.zip", "ub") the error is "c_proc/c_func: argument list 
>must be a sequence ", so what to do ?
>puts(1,ok) --end code

  Since ZipFile is a string, it must be passed via a pointer. The function 
should read:

--
include dll.e
include machine.e

atom bszip, lpZipFile
integer OpenZipFile, ok
sequence ZipFile
bszip = open_dll("bszip.dll")
ZipFile = "c:\\indisp.zip"
OpenZipFile = define_c_func(bszip, "zOpenZipFile", {C_POINTER}, C_INT)
-- Allocate pointer for string
lpZipFile = allocate_string(ZipFile)
ok = c_func(OpenZipFile, {lpZipFile})
-- Make sure to free allocated space
free(lpZipFile)
puts(1,ok) --end code

>Another question : how to get the actual filename from a file number ( eg   
>  c:\indisp.zip vs 1342177280 ) ?
>

  I don't know how to do that. Try looking at the docs for the DLL.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu