Tutorial 42 - Pointers

Written By Akki On Friday, November 16, 2007

Tutorial 42 - Pointers

Pointers

Ah, the wonderful world of pointers! Have you ever read about them or heard about them? The cause of programmer's nightmares all around the world. Even if PPL allow you to live without them, you still can use them to expand the power of your programs.

Lets start with string pointers. Strings in PPL are stored pretty much like any other strings in other programming languages. Each byte represents a character. If you define a string, you can later on access its pointer value and go to a specific character by adding a value to it.

s$ = "HELLO WORLD";
i$ = &s$ + 3;
ShowMessage(@i$);

The following code will display "LO WORLD" in a dialog. The value of variable i$ will be the pointer location of s$ in memory plus the value 3. Now i$ is a simple numerical variable, nothing more. We need to convert it back into a string. The @ operator is used to convert a numerical value into memory content.

Share and Enjoy:
  • del.icio.us
  • StumbleUpon
  • Digg
  • Sphinn
  • Facebook
  • Mixx
  • Reddit
  • Technorati
  • IndianPad
  • YahooMyWeb

No Comments