Forum Discussion

markus_humm's avatar
markus_humm
Occasional Contributor
14 years ago

Log.Message with multiline

Hello,



I'm using Delphi Script. I can write the contents of a ComboBox into the log via



log.Message(combo.wItemList);



This writes the items as multiline text into the log. According to the documentation

log.Message doesn't support multiline text as first parameter.



I want to have a text prefix that wItemList, but in it's own line like:



My text

item1

item2

item3



log.Message('MyText '+wItemList); obviously doesn't do the trick.

How can wItemList do this?



Greetings



Markus

6 Replies

  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Jeremy, I think it may be the way the Log Viewer works. If you hover over the Log Message in the Viewer does it appear as expected, as such?

     




     


    Regards,


    Phil Baird

  • Hi Markus,



    You need to insert newline characters to the string you pass to Log.Message:

    ...

    Log.Message('First line' + Chr(13) + Chr(10) + 'Second line');

    ...




    See the "Special characters" section of the "DelphiScript - Working With Strings" help topic.
  • markus_humm's avatar
    markus_humm
    Occasional Contributor
    That works, thanks. I had just hoped to find a system constant or something like that which covers this.
  • Instead of creating a new topic...along the same lines, can someone tell me why this doesn't work in JScript?



    Log.Error("Line one " + "\nLine two");



    Expected Result:

    Line one

    Line two



    Actual Result:

    Line oneLine two



    I also tried \r but that doesn't work either.
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    As Phil suggested it's likely printing the newline character, but you aren't seeing it because the log only shows the top most line for the current record.
  • Ok yep it works just like Phil decribed, I never would've expected that. I suppose I will just do two Log.Error's instead and call it a day.



    Thanks for the heads up!