Devis Posted June 23, 2012 Share Posted June 23, 2012 Hi there, Ive been reading alot of tutorials on TForms, and im creating a button for a TForm. But I want the caption on the button to be spread over 2 lines, instead of one long line of text. At the moment my Text is: CloseBut.Caption :='Shut Down Program.'; But I saw on a tutorial something like: CloseBut.Caption :='Shut Down' + #10#13 + 'Program.'; To make the Shut Down and Program on seperate lines.. but cant get it to work.. just wondered what the right code is and what the "#10#13" means? Thanks Quote Link to comment Share on other sites More sharing options...
LordJashin Posted June 23, 2012 Share Posted June 23, 2012 (edited) Hi there, Ive been reading alot of tutorials on TForms, and im creating a button for a TForm. But I want the caption on the button to be spread over 2 lines, instead of one long line of text. At the moment my Text is: CloseBut.Caption :='Shut Down Program.'; But I saw on a tutorial something like: CloseBut.Caption :='Shut Down' + #10#13 + 'Program.'; To make the Shut Down and Program on seperate lines.. but cant get it to work.. just wondered what the right code is and what the "#10#13" means? Thanks Just tested it. For TButton's. There is a WordWrap property. Once you set that, if the caption exceeds the width of the button it will go to the next line. No '/n' new line special character needed. Always check for Multiline and WordWrap properties. [sCAR] var a: TButton; begin a.WordWrap := True; end. [/sCAR] #10#13, is the special code for new line in delphi or w/e. If you know C language (/n) or text encoding it is the equivalent of a NEW LINE, or Carriage return I think in ASCII or some other encoding format. Edited June 23, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Devis Posted June 23, 2012 Author Share Posted June 23, 2012 Thanks Works perfectly, and thanks for the explanation on the #10#13 code. IS some delphi code implemented into SCAR? Ive noticed on some tutorials they refer to delphi code. Im a nooby a coding so dont really know much about it hehe Quote Link to comment Share on other sites More sharing options...
FHannes Posted June 23, 2012 Share Posted June 23, 2012 Thanks Works perfectly, and thanks for the explanation on the #10#13 code. IS some delphi code implemented into SCAR? Ive noticed on some tutorials they refer to delphi code. Im a nooby a coding so dont really know much about it hehe SCAR is written in Delphi which is a form of Object Pascal, SCAR's script engine also offers an Object Pascal based language, the result is that most principles are exactly the same as they are in Delphi. Quote Link to comment Share on other sites More sharing options...
Devis Posted June 30, 2012 Author Share Posted June 30, 2012 Just for reference incase anyone wants to know. +Chr(10)+ Is the code used to make text go onto a second line manualy without using the TextWrap feature. For example: [scar]program New; begin Writeln('Hello' +Chr(10)+ 'World!'); end.[/scar] Outputs: Successfully compiled Hello World! Successfully executed Useful for usage in button captions, Forms, and messages such as ShowMessage(); when you want to manualy decide what text is on each line. Quote Link to comment Share on other sites More sharing options...
FHannes Posted June 30, 2012 Share Posted June 30, 2012 It's actually #13#10 or Chr(13) + Chr(10) in Windows, #10 is the newline character which is the default for Unix, Windows prepends the #13 return character, but the debugbox accept either format. However, take in mind that when writing files which other apps are required to open, you should use #13#10. Quote Link to comment Share on other sites More sharing options...
Devis Posted July 1, 2012 Author Share Posted July 1, 2012 Ahh I see now. Thanks for the explanation Freddy Quote Link to comment Share on other sites More sharing options...
LordJashin Posted July 1, 2012 Share Posted July 1, 2012 Using that method in forms, you can make a new line whenever you want. But with the WordWrap property you are ensured that once the text cannot fit in the control's room for text it will go to the next line. Quote Link to comment Share on other sites More sharing options...