Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Pascal - <b> string string variable pp 41</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 STRING                        String Variable                         pp 41


 Define:  An array of characters up to 255 bytes long.

 Purpose: Read and Write characters to files and console.

 Notes:   A variable of type String occupies its length + 1 bytes
          in memory.  The extra byte is the length byte which is the
          first byte of the string.  Length byte = Ord (String [0]).

          A string 'Constant' is not permanently fixed.
          It can be written to and changed up to its defined length.


 ----------------------------------------------------------------------------


 Usage:
       CONST
          StrVar : String [8] = '1234';   { Define as 8 bytes max   }

       BEGIN
          WriteLn (Ord(StrVar[0]));       { The actual length is 4  }
          StrVar := '123456789ABC';       { Re-write to 8 bytes max }
          WriteLn (Ord(StrVar[0]));       { The new length is 8     }
          WriteLn (StrVar)        ;       { '12345678'              }
       END.

See Also: Concat Copy Delete Insert Length Pos

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson