Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Using Memblocks and pointers

Author
Message
ProfessorKill
22
Years of Service
User Offline
Joined: 3rd Nov 2003
Location: Frederick, MD
Posted: 29th Nov 2003 22:00
I'm having a bit of trouble using memblocks. Here's what I'm trying to do and getting various errors...

1. Create a small memblock of 128 bytes
2. Create pointer to the memblock
3. Write a string into the block
4. Use a pointer to pass the memblock into a dll
5. Read a value in a memblock and print it out.

Very simple I'm sure, but I really can't find any tutorials on using memblocks. The search feature for this forum is horrible. The help files in DBP are even more horrible.

Can someone post a quick snippet which will do the above?

Thanks in advance for your help. I really need it
ProfessorKill
22
Years of Service
User Offline
Joined: 3rd Nov 2003
Location: Frederick, MD
Posted: 29th Nov 2003 23:02 Edited at: 29th Nov 2003 23:07
Ok, this seems to work...

    make memblock 1, 8
    mName = get memblock ptr(1)
    *mName = "ProfKill"

The value "ProfKill" is written to the memblock. Now how can I "Print" what is in a memblock?

Is this bad code? Meaning is there an easier way to do this?

Thanks again
the_winch
23
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 29th Nov 2003 23:05


dbpro : p166mmx @ 233 : 256mb : sb 128pci : sis onboard
ProfessorKill
22
Years of Service
User Offline
Joined: 3rd Nov 2003
Location: Frederick, MD
Posted: 29th Nov 2003 23:09
Ok, so I'm -not- using the pointer (*) correctly?

Thanks for your reply
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Nov 2003 12:15
Grab the utility DLL from my site - it has peek and poke for all types including strings
ProfessorKill
22
Years of Service
User Offline
Joined: 3rd Nov 2003
Location: Frederick, MD
Posted: 1st Dec 2003 03:44
@IanM

The GET STRING PTR function is nice. Working well for me. I haven't tried yet but can I do this...

Buffer$ = space$(32)
call dll 1, "BlahBlahFunction", GET STRING PTR(Buffer$)

Will the dll be able to write a value into Buffer$? And then I could just print Buffer$?

Mark
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Dec 2003 03:58 Edited at: 1st Dec 2003 03:59
Yep. I do that myself sometimes



You just have to be careful to remember that strings are null-terminated and are 1 character longer than the length reported.
ProfessorKill
22
Years of Service
User Offline
Joined: 3rd Nov 2003
Location: Frederick, MD
Posted: 1st Dec 2003 04:06
So I don't have to use GET STRING PTR?

Passing a string variable name into a dll passes in a pointer, not the string?
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Dec 2003 13:10
When you pass a string to an external DLL in this way it passes the pointer to the string already, although using the GET STRING PTR() would work too.
ProfessorKill
22
Years of Service
User Offline
Joined: 3rd Nov 2003
Location: Frederick, MD
Posted: 2nd Dec 2003 14:23
IanM

Did you get my email? I can't get to my email from work so I haven't had a chance to see if you replied.

Assuming you did get the email...

What are your thoughts? Does a dll or plug-in like that already exist? Assuming no, would that be an easy dll/plug-in to write? Is that something you might do for a fee?

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Dec 2003 14:34
I have got your mail ... I just hadn't decided on how to reply to it yet

I'll reply now

Login to post a reply

Server time is: 2026-07-26 20:16:38
Your offset time is: 2026-07-26 20:16:38