Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / How to write code in s...
Finance forum
Suggested answer

How to write code in separate line but continued ?

Posted on by 338
Hi guys,
 
When writing code in X++ often I want to split my statement into different (separate) line. for example with this code :
 
io.write(/DATE,ACCOUNT_TYPE,ACCOUNT_CODE,HQ_OR_CLUB,DIVISION,BUSINESS_UNIT,CLASSIFICATION,PROJECT,EMPLOYEE,COSTALLOCATION,DESCRIPTION,AMOUNT, 
                    OFFSET_ACCOUNT_TYPE,ACCOUNT_CODE_1,HQ_OR_CLUB_1,DIVISION_1,BUSINESS_UNIT_1,CLASSIFICATION_1,PROJECT_1,EMPLOYEE_1,COSTALLOCATION, 
                    REFERENCE_NO,GST,DUE_DATE,INVOICE,TERM_OF_PAYMENT,DOCUMENT_DATE,DOCUMENT_NUMBER,METHOD_OF_PAYMENT,BASE_AMT_TAX,CLM_TYPE_DESC,EXPENSECODE/);
 
How to fix since I got error : /  Unterminated string constant.  /
 
 
Thanks
  • Martin Dráb Profile Picture
    Martin Dráb 223,308 Super User on at
    How to write code in separate line but continued ?
    As Waed pointed out, you didn't follow my example correctly. By the way, the syntax in C# is the same.
     
    Here is the documentation: String > String Literals.
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 2,526 on at
    How to write code in separate line but continued ?
    Hi,
     
    You should use it like this:
    string text = @"My pensive SARA ! thy soft cheek reclined
    Thus on mine arm, most soothing sweet it is
    To sit beside our Cot";
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Teevo Profile Picture
    Teevo 338 on at
    How to write code in separate line but continued ?
    Hi,
     
    Thanks, Actually I never heard of using this verbatim, and cannot find X++ documentation regarding this ? 
    May I know how exactly to use it ?
     
    Definitely not like this I supposed, since it is error ->
    I tried with space, add the sign in front of each string in the next line, no luck as well. 

    Noted about the FileStream, I will try after this is solved.
    Thanks
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    Navneeth Nagrajan 1,225 on at
    How to write code in separate line but continued ?
    Hi,
     
    You can use @ as suggested by Martin. Would recommend using FileStream instead of the TextStreamIO (which only perform write operations). With FileStream you have more flexibility to perform both read and write operations, if in case that's your requirement.
     
     
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 223,308 Super User on at
    How to write code in separate line but continued ?
    You can use a verbatim string (prefixed with @). For example: @"...".

    Note that you can find these things in X++ documentation.
  • Teevo Profile Picture
    Teevo 338 on at
    How to write code in separate line but continued ?
    Hi,
     
    Yes, I know this. But the intention is I don't want couple of variable join into 1. The code in mine already have (" ") , but because it is too long and hard to read, I want to move some of the statement into the next line to make easy to read. 
     
    If I remember correctly, if it is C# we can use "_" to make long statement into multi line, unless I'm wrong.
     
    Thanks.
  • Suggested answer
    rajborad Profile Picture
    rajborad 170 on at
    How to write code in separate line but continued ?
    HI Teevo,
     
    Try to store a string in a variable and use it in your method.
    io.write(yourVariable);


     
     

Helpful resources

Quick Links

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,377 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans