Re: Sequence-Atom-DLL
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 02, 2003
- 392 views
----- Original Message ----- From: <president at insight-concepts.com> To: "EUforum" <EUforum at topica.com> Subject: Sequence-Atom-DLL > > > Hi, > > I have been practicing creating and using .DLLs with Euphoria and the C > Translator. > > I created a small .dll with a procedure File_Compress(sequence infile, > sequence outfile, > sequence setting) > > When trying to call the procedure from a test application, I get an > error "Fatal run-time error: device or file name must be a sequence" > > I tried changing the data to a sequence and then I received and error > that arguments to C routines must be atoms. > > My question is how do I pass the sequence to the dll if arguments to C > routines must be atoms ? > You might have to pass the 'string' as an address. So in the calling program you do this... atom infileA, outfileA, settingA infileA = allocate(length(InFileName) + 1) poke(infileA, length(InFileName)) poke(infileA+1, InFileName) outfileA = allocate(length(OutFileName) + 1) poke(outfileA, length(OutFileName)) poke(outfileA+1, OutFileName) settingA = allocate(length(Setting) + 1) poke(settingA, length(Setting)) poke(settingA+1, Setting) c_proc(comp, {infileA, outfileA, settingA} ) free(infileA) free(outfileA) free(settingA) And in the 'dll' code ... procedure File_Compress(atom InFile, atom OutFile, atom Setting) sequence infilename, outfilename, setttings atom len len = peek(InFile) infilename = peek({InFile+1, len}) len = peek(OutFile) outfilename = peek({OutFile+1, len}) len = peek(Setting) settings = peek({Setting+1, len}) . . . end procedure This what you would have to do with a C written DLL. And BTW, this method assumes strings are less than 256 bytes. -- Derek