AGS Pointers for Dummies: Difference between revisions

Line 112: Line 112:
With the introduction of AGS 2.71 came the new String type which removed that limit. And how did it do it? It used a pointer. Not an AGS-style pointer, but a pointer nonetheless. In programming languages such as C and C++, a pointer-to-char (char*)<sup>6</sup> creates a special type of pointer. Instead of just pointing to one single variable, a char* can point to a virtually infinite number of chars in the form of what is known as a string-literal (such as "this is some text").
With the introduction of AGS 2.71 came the new String type which removed that limit. And how did it do it? It used a pointer. Not an AGS-style pointer, but a pointer nonetheless. In programming languages such as C and C++, a pointer-to-char (char*)<sup>6</sup> creates a special type of pointer. Instead of just pointing to one single variable, a char* can point to a virtually infinite number of chars in the form of what is known as a string-literal (such as "this is some text").


Since AGS uses a special type of pointer for managing the String type, it can still hold the value '''null''' (this is what Strings are initialized to), and when used as a function parameter, can be made optional in the same manner (see the section on [[#Optional_Parameters|optional parameters]] for more information).
Since AGS uses a special type of pointer for managing the String type, it can still hold the value '''null''' (this is what Strings are initialized to), and when used as a function parameter, can be made optional in the same manner (see the section on [[#Optional_Pointer_Parameters|optional parameters]] for more information).


<sup>6</sup>'''<font size="1">In AGS you can't create a char*, as char isn't one of AGS's managed types. This type of pointer is used in scripting languages like C and C++. For storing string-literals AGS uses the String type (or the string type for AGS versions prior to 2.71).</font>'''
<sup>6</sup>'''<font size="1">In AGS you can't create a char*, as char isn't one of AGS's managed types. This type of pointer is used in scripting languages like C and C++. For storing string-literals AGS uses the String type (or the string type for AGS versions prior to 2.71).</font>'''
Anonymous user