Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Anyone interested in making a text adventure as a group?
Pointers also allow you to use memory on the Free Store. Think of your normal Dimmed variables as cubbyholes. When you DIM a variable, you put a label on a cubbyhole. So I have cubbyhole with a label on it now. You can do anything using that label.

The Free Store is a bunch of cubbyholes already made by the computer. However, you can not label these. Instead, you can access it through its address. Take this as an example.

Code:
Dim myptr As Integer Ptr        'A pointer to an Integer.

myptr = Allocate(len(Integer))          'Allocates 4 cubbyholes on the
                                                         'Free Store, then puts the
                                                         'Address in myptr.

Now you really can't do anything with myptr. It's just a Pointer to a cubbyhole on the Free Store. However, now you can put anything you want in that cubbyhole using your pointer. Things done directly on the free store tend to be faster than regular variables. The way to put the number 256 in the cubbyhole, is to use the DeReference operator (*). Like this:

Code:
*myptr = 256

Notice the asterisk (*). This is very important. The asterisk means "The cubbyhole at". So this would be read as "The cubbyhole at myptr gets 256". You see?

This is only one of the many uses of pointers. They don't seem very useful at first (and truthfully I haven't used them much either) but they are one of those tricks of the trade, that you will learn as you go along.[/code]
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply


Messages In This Thread
been thinkin - by zoasterboy - 10-22-2005, 10:54 AM
sorry! - by phycowelder - 10-23-2005, 12:13 PM
before... - by zoasterboy - 10-24-2005, 07:43 AM
story line - by zoasterboy - 10-25-2005, 04:47 AM
yah - by zoasterboy - 10-25-2005, 07:26 AM
main menu - by zoasterboy - 10-26-2005, 05:13 AM
joining - by phycowelder - 10-26-2005, 05:25 AM
^^ - by zoasterboy - 10-26-2005, 05:27 AM
Anyone interested in making a text adventure as a group? - by Anonymous - 10-26-2005, 05:34 AM
Re: ^^ - by Liquid Snake - 10-26-2005, 06:18 AM
cool! - by phycowelder - 10-26-2005, 06:56 AM
Anyone interested in making a text adventure as a group? - by Torahteen - 10-31-2005, 08:56 PM

Forum Jump:


Users browsing this thread: 6 Guest(s)