New line in a string

philippegirodphilippegirod Member Posts: 191
edited 2004-02-05 in Navision Attain
:roll: For a beginner in C/side (me)...
What is the expression to have a new line in a string, for instance if I want to have a message with 2 lines what is the syntax (I know it for other languages, like '\n')?

//example
text01 := 'first line..... second line';
MESSAGE(text01);
My candle burns by both ends, it will not last the night,
But oh my foes and oh my friends, it gives a lovely light

Comments

  • DenSterDenSter Member Posts: 8,307
    //example
    text01 := 'first line\second line'; // you need the backslash
    MESSAGE(text01);
    

    HTH,
    Daniel
  • philippegirodphilippegirod Member Posts: 191
    Thanks a lot for your answer, it is exactely what I wanted.

    Is there a way to have a new line in a Tooltip on a form ?
    The '\' doesn't work apparently.

    Definitely, I'm a beginner.........
    My candle burns by both ends, it will not last the night,
    But oh my foes and oh my friends, it gives a lovely light
  • DenSterDenSter Member Posts: 8,307
    I don't know, I've never had the need to change tooltips.
  • Timo_LässerTimo_Lässer Member Posts: 481
    [...]
    Is there a way to have a new line in a Tooltip on a form ?
    The '\' doesn't work apparently.
    [...]
    I tried this some years ago but I got no solution to do this. :roll:
    I think it is not possible to have a new line in a Tooltip :(
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • philippegirodphilippegirod Member Posts: 191
    The '\' doesn't works inside a STRSUBSTNO,
    For instance if I have this code :
    TextInReport := STRSUBSTNO('%1\%2',Rec.Field1,Rec.Field2);
    
    The result is "Text of the field 1\Text of the field 2"

    How to have a new in this case ?

    Thanks again for all your help.
    My candle burns by both ends, it will not last the night,
    But oh my foes and oh my friends, it gives a lovely light
  • Timo_LässerTimo_Lässer Member Posts: 481
    The '\' doesn't works inside a STRSUBSTNO,
    For instance if I have this code :
    TextInReport := STRSUBSTNO('%1\%2',Rec.Field1,Rec.Field2);
    
    The result is "Text of the field 1\Text of the field 2"

    How to have a new in this case ?

    Thanks again for all your help.
    If you want to print this in a label / textbox, you have to set the property 'MultiLine' to 'Yes'.
    Note: The control must be long enough to show one whole line. Otherwise the new line doesn't work. :roll:
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • philippegirodphilippegirod Member Posts: 191
    Yes, of course..... I knew those important things.
    But the problem occurs only in a report.
    I can have a text box in a form with several lines, in a message too but not in a report.
    In the report, Navision print '\' instead of give a new line. I suppose there is an other syntax to have new line, but I don't know which.
    My candle burns by both ends, it will not last the night,
    But oh my foes and oh my friends, it gives a lovely light
  • GoMaDGoMaD Member Posts: 313
    Ignore this post!

    I thought that I had the solution, but it didn't work.
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • philippegirodphilippegirod Member Posts: 191
    The only solution I could find is to have a text var with dimensions (as many as new line needed).

    Then, when the condition to change the line is there I can use that kind of code :
    i := i+1;
    VarText[i] := STRSUBSTNO('%1 ',Table.Field);
    

    Then, in the report I have a new Table body for each dimension possible and in the OnPreSection trigger I simply use this code (for instance) :
    IF VarText[3] = '' THEN CurrReport.SHOWOUTPUT(FALSE);
    
    My candle burns by both ends, it will not last the night,
    But oh my foes and oh my friends, it gives a lovely light
  • RajeshjRajeshj Member Posts: 1
    You can find solution on www.Navision.Net website for this query. Please find Line Feed or Carraige Return in search window.
    Jaiswal Rajesh Kumar
Sign In or Register to comment.