DelphiBasics
PShortString
Type
A pointer to an ShortString value System unit
  type PShortString = ^ShortString;
Description
The PShortString type is a pointer to an ShortString value.
 
ShortString variables differ from string variables - the latter are referenced by a pointer. So you must use Addr to point to a ShotrString variable, as in the exemple.
Related commands
PString Pointer to a String value
ShortString Defines a string of up to 255 characters
String A data type that holds a string of characters
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Display a short string using a pointer to it
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  // The System unit does not need to be defined
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  myString  : shortString;
  stringPtr : PShortString;

begin
  // Set up our short string
  myString := 'Hello World';

  // Point to our string
  stringPtr := Addr(myString);

  // Display the string using the pointer
  ShowMessage(stringPtr^);
end;
 
end.
Hide full unit code
   Hello World
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page