0

Are they something like the primitive and the class type one, each?

For

function binaryFormat (binary:String; n:Integer) : String;

and

function binaryFormat (binary:String; n:Integer) : string;

would their result values be the same?

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
diegoaguilar
  • 8,179
  • 14
  • 80
  • 129
  • 1
    And StRiNg and ..... :-) You know that F1 key on your computer? Delphi actually has a pretty good language guide. – Warren P Jun 16 '13 at 19:39
  • 1
    The suggestion to try `StRiNg` is not really useful. I got to this question after reading [Object Pascal Style Guide](http://edn.embarcadero.com/article/10280 "Object Pascal Style Guide"): here `string` is definitely spelled right, here it's not: [System.String – RAD Studio API Documentation](http://docwiki.embarcadero.com/Libraries/Tokyo/de/System.String "System.String – RAD Studio API Documentation"). – Wolf May 09 '18 at 10:06

2 Answers2

9

Delphi is not case-sensitive, so string, STRING, stRIng and String are all the same.

I referred you to a Pascal tutorial in a previous question. Please use it.

Community
  • 1
  • 1
Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Worth noting, also, that unlike in .NET programming, there is no String class in Delphi - it is a type only. The general type of functionality of the static String methods in .NET are to be found in the StrUtils unit in Delphi. – J... Jun 16 '13 at 12:48
  • @J: Also worth nothing that if Diego would read one of the tutorials suggested in the linked previous question, there would have been no need to ask this question or not know about having no `String` class in Delphi. :-) – Ken White Jun 16 '13 at 15:54
  • @KenWhite - yes, no question there. Cantu is an invaluable resource! – J... Jun 16 '13 at 23:24
  • The answer has very limited value now. No sensible programmer would ever seriously use `stRIng`, but indeed the spellings `String` and `string` are used and the coding conventions disagree about this. – Wolf May 09 '18 at 09:58
6

In Delphi, the built-in types usually start with a capital letter, and I have seen a lot of Delphi code where String is used, as if there was a type with this name. But this is wrong, there is no String type (with a capital first letter) - so String is just a spelling error.

The correct spelling is string (all lower case), and it is an alias for UnicodeString (in Delphi 2009 and up), see http://docwiki.embarcadero.com/RADStudio/XE3/en/String_Types

mjn
  • 36,362
  • 28
  • 176
  • 378
  • 1
    To be precise, the "correct spelling" is the word `string`, regardless of case. Typing the initial letter lowercase is simply a coding convention adopted by Borland (and usually followed by others), as is the use of the letter `T` as the first character of type names. (Borland in fact was a little inconsistent, as the use is `string` (lower case), but `Boolean`, `Integer`, `Cardinal`, `Extended`, and `Double` (capitalized) for other types. – Ken White Jun 16 '13 at 20:08
  • 2
    @KenWhite "string" is a reserved word in Delphi, and so is written using all lowercase, just like other reserved words (e.g. "if", "then"). OTOH; "Boolean", "Integer" etc are *not* reserved words, so they are written with the first letter uppercase. There is no inconsistency. – awmross Jun 17 '13 at 06:06
  • 1
    ... it's also that `string[20]` is very different from `string` - the problem is that `string` was an alias for `string[255]` before Delphi, now you need to explicitly declare short strings as `string[255]` or `ShortString`. In former Delphi versions `string` was an alias for `AnsiString`. I think the answer could be expanded to also cover the facets *reserved word*, *coding conventions* and *transition in meaning*. Nevertheless it's a much better starting point for understanding the real issue than the accepted answer. – Wolf May 09 '18 at 09:49