# Ruby / DL problem

**URL:** <https://www.ruby-forum.com/t/ruby-dl-problem/61518>\
**Category:** Ruby\
**Created:** [May 24, 2006, 6:37pm UTC](https://www.ruby-forum.com/t/ruby-dl-problem/61518 "2006-05-24T18:37:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bama\_Test](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@Bama\_Test](https://www.ruby-forum.com/u/Bama_Test)\
**Post date:** [May 24, 2006, 6:37pm UTC](https://www.ruby-forum.com/t/ruby-dl-problem/61518/1 "2006-05-24T18:37:19Z")

</div>

I’ve got a DLL that I’m working on interfacing to - i’ve got everything  
working except for this one function.

int CreateDataFile ( const char\* csUserID,  
const char\* chOptionalTemplateFilePath,  
const char\* csPrefix,  
const char\* csSuffix,  
char\*& newFileID);

the problem is with the newFileID parameter - it’s defined as “points  
to the buffer that receives the string of the File ID created. Maximum  
length of this buffer is 20 bytes.”

I’ve tried defining the call as both  
@createfile = msg[“CreateDataFile”, “ISSSSP”]  
and  
@createfile = msg[“CreateDataFile”, “ISSSSS”]

and then passing in the values like this  
x = “”  
ptr = DL.malloc(20)  
a = @createfile.call(‘eldon’,x,x,x,ptr)

the function runs successfully but I can’t ever retrieve the value of  
the FileID created from ptr and from what I can tell It still looks  
empty. So I figure I must either be defining it incorrectly or passing  
it in the call wrong. From my memory of C the & is actually a pointer  
to a memory location, but there seems something in my memory that it  
might mean something different when referenced like this (it’s been  
like 10 years since i did anything in C) and I’ve done a ton of google  
searches already.

Any guesses as to what i might be doing wrong?

Thanks

Eldon

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[Yahoo Mail - Organized Email](https://mail.yahoo.com)**
>
> It's time to get stuff done with Yahoo Mail. Just add your Gmail, Outlook, AOL or Yahoo Mail to get going. We automatically organize all the things life throws at you, like receipts and attachments, so you can find what you need fast. Plus, we've got...

---

<div class="post-metadata">

**Author:** ![Bama\_Test](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@Bama\_Test](https://www.ruby-forum.com/u/Bama_Test)\
**Post date:** [May 25, 2006, 5:03am UTC](https://www.ruby-forum.com/t/ruby-dl-problem/61518/2 "2006-05-25T05:03:28Z")

</div>

Hi,

> ```
> const char* chOptionalTemplateFilePath,
> 
> ```
> 
> and  
> it in the call wrong. From my memory of C the & is actually a pointer  
> to a memory location, but there seems something in my memory that it  
> might mean something different when referenced like this (it’s been  
> like 10 years since i did anything in C) and I’ve done a ton of google  
> searches already.
> 
> Any guesses as to what i might be doing wrong?

define like this  
@createfile = msg[“CreateDataFile”, “ISSSSP”]

and call like this

ptr = “\0” \* 20  
a = @createfile.call(‘eldon’,x,x,x,[ptr].pack(“P”))  
puts ptr

Regards,

Park H.
