Talk:Character and string types
Is the sentence in Character_and_string_types#Array_of_Char, delivers: a b c d #0 since arrays are filled with null-bytes in Free Pascal correct?!
I've tested (Lazarus 1.2.2 r44758 FPC 2.6.4 i386-win32-win32/win64 and Lazarus 1.3 r45097M FPC 2.7.1 i386-win32-win32/win64 on Win7)
procedure TForm1.Button1Click(Sender: TObject); type TOldString4 = array[0..4] of char; var aOldString4: TOldString4; begin aOldString4 := 'a'; aOldString4 := 'b'; aOldString4 := 'c'; aOldString4 := 'd'; writeln('['+aOldString4+']'); Caption:=IntToStr(ord(aOldString4)); end;
I got different results, but not #0 for aOldString4. So, do I have to update the facts or do I missunderstood the statement?
Thanks --Michl 23:10, 1 June 2014 (CEST)
- That statement is indeed completely bogus, there is no guarantee whatsoever regarding the content of that array element. Maybe the author was confused because of dynamic arrays, whose empty positions are initially initialised with 0 (or #0, or nil, or ...).
- Jonas 11:37, 2 June 2014 (CEST)
- All global variables are always initialised with 0/#0/nil/... That is documented in the manual, has nothing to do with array of char, and should therefore not be mentioned here because it is orthogonal.
- Jonas 14:43, 2 June 2014 (CEST)
- Thank you Jonas, I did not question your statement was just surprised that when several attempts always an array filled with # 0 was created. Strange coincidences, please excuse my rude behavior and my not so good English.
- I have now differentiated by static and dynamic array of char. If you or anyone else wants to, so someone could let's see, whether in terms of content and of the spelling, is in order.
- Thank you! --Michl 21:19, 2 June 2014 (CEST)
Doesn't ANSIChar contain an ANSI character instead of ASCII? I.e. it is codepage dependent but can contain byte values 0..255?
--BigChimp 15:28, 28 December 2013 (CET)
- This is the information of the official FPC documentation. I will do additional research.
- --Jwdietrich 15:33, 28 December 2013 (CET)
- Yes, I suspect the official FPC documentation is wrong/incomplete ;)
- BTW: thanks for writing this page - it's very helpful!
- --BigChimp 16:53, 28 December 2013 (CET)
- Thanks for your positive feedback. In fact, it is ANSI. Although the official Free Pascal documentation states that a char contains an ASCII character, is is stored as a byte to use extended ASCII or ANSI.
- --Jwdietrich 16:55, 28 December 2013 (CET)
- Hope I fixed that. --Bart (talk) 18:07, 15 January 2017 (CET)
- I believe you did a magnificent job already there Bart. Thank you very much for that, and apologies for being lazy myself. I noticed there are also many inconsistencies with regards to using anchors (or not) so my initial thought was to mark this as "links broken" and fix it after it was more clear to me for which case(s) to use anchors (or not). At the least you've made the links point to relevant reading material now. :-) --Molly (talk) 20:22, 15 January 2017 (CET)