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 / better explaination pointers in db..

Author
Message
HAL
23
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 25th Apr 2003 00:56
doe's anyone have a better explaination pointers? in the help docs it says ` Ptr as DWORD
Ptr=0x00FF8820
*Ptr=42
PRINT *Ptr
The above code simply declares Ptr as a DWORD variable, assigns the variable a
random area of memory, writes the value 42 into that location of memory and
then reads the same address back, the contents of which is to be printed to the
screen.`
does this mean it's possible to get an address of a variable, doesn't `Ptr=0x00FF8820` just assign Ptr the value of the hex number? plus if this number is low it causes an error, any ideas.
also is this code working right.

i'm not sure how a number that large can still return 42(0x2A).
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 25th Apr 2003 01:28
With the pointer system, you shouldn't really assign random addresses - you should always do it with allocated memory like :

ptr as DWORD
ptr=make memory(1024) - which assigns some value to ptr

You can then safely put data in or get it out safely :

print chr$(*ptr) - prints the character stored in the memory address held by ptr

To be honest, and to put in a bit of self-advertising, it would be much easier for you if you use my peek/poke routines.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Apr 2003 01:47
... or mine

If you have an aversion to plugins for any reason, here is a set of PEEK/POKE functions written using pure DBPro that will run just as fast as the plugins (except for the string ones):



PS. Don't try the PeekString/PokeString functions without using SYNC ON - they will take ages to run otherwise.
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 25th Apr 2003 01:58
Yes, Plug-in Adversion Syndrome - PIAS... its very odd...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
HAL
23
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 25th Apr 2003 03:42
lol, PIAS and ATDTTEW-Syndrome (adversion to doing things the easy way).
it looks like i've got bigger problems at the moment tho, its seems global variable don't work very well in dll's. a door opens then there's another door behind it.
neat code IanM, going to look at the plug-in thing tomorrow, i see the site's had a face-lift.. thanks for the help.

Login to post a reply

Server time is: 2026-07-10 18:02:18
Your offset time is: 2026-07-10 18:02:18