ShortString: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
Title: ShortString Shortstring
| Old | New | | Line |
|---|
| 1 | | - | **Memory requirement:** 256 bytes (1 byte for the length specification and 255 bytes for the characters). |
| 2 | | - | |
| 3 | | - | **Property:** The [[Data field|data field]] of the [[Data type|data type]] Shortstring is an array, made up of data fields of the data type [[Char]]. Its length is defined as: `ShortString = String[255];` |
| 4 | | - | |
| 5 | | - | ShortString has the same properties as the string in Turbo Pascal. |
| 6 | | - | |
| 7 | | - | Definition of a data field of the data type ShortString: |
| 8 | | - | |
| 9 | | - | ``` pascal |
| 10 | | - | var |
| 11 | | - | s : ShortString; |
| 12 | | - | ``` |
| 13 | | - | |
| 14 | | - | Examples for the valid assignment values: |
| 15 | | - | |
| 16 | | - | ``` pascal |
| 17 | | - | s := '0123ABCabc456'; |
| 18 | | - | s := s + '! "§ $% & / () =?'; |
| 19 | | - | s := 'c'; |
| 20 | | - | s := s + IntToStr (45); |
| 21 | | - | ``` |
| 22 | | - | |
| 23 | | - | Examples of invalid assignment of values: |
| 24 | | - | |
| 25 | | - | ``` pascal |
| 26 | | - | s := True; |
| 27 | | - | s := 4; |
| 28 | | - | ``` |
| 29 | | - | |
| 30 | | - | ## Caveats |
| 31 | | - | |
| 32 | | - | > **Warning:** `low(myShortString)` returns `0`, i. e. the index of the length Byte, not the first character’s index. Likewise, `high(myShortString)` always returns `255`. Use `length` instead. |
| 33 | | - | |
| 34 | | - | Nevertheless, a [[for-in loop|for … in loop]] will work as expected. |
| 35 | | - | |
| 36 | | - | ## See also |
| 37 | | - | |
| 38 | | - | - [[Data type|Data types]] |
| 39 | | - | - [[Character and string types]] |
| 40 | | - | |
| 41 | | - | --- |
| 42 | | - | *From the Free Pascal wiki, page "ShortString", as it stood on 2023-12-22 after a change by Alextpp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
| 43 | | - | Category: Data types |
| 44 | | - | Category: FPC |
| 45 | | - | Category: RTL |
| 1 | + | #REDIRECT [[ShortString]] |
Back to history