Multiline string value

Options

Is there any comfortable way to define multiline string value in OScript?

I need something like this:

sqlQuery = """SELECT

objf.sys_name,

objf.ui_name,

objf.show_order,

ftype.system_name as type

FROM

object_field objf,

field_type ftype

WHERE

objf.object_type_id = 1

AND objf.field_type_id = ftype.id

"""

Tagged:

Comments

  • Victor,

    try using ` instead of ' when defining the string. ex:

    public String fWhatever = `select *

    from Kuaf

    where name = :A1`

    Cheers...

  • Thanks John. Unfortunately the module is not being built with this syntax.

    I have a build error in the module tree but no comments from the compiler.

    If you tell where to find build logs I can try to find details.


  • UPDATE: I found the compiler error message: incorrect syntax, unexpected LONGSTRING

  • Hiya - it sounds like something is fundamentally odd syntactically in your OS file. The error implies that you did indeed enter the long string with ` characters (so that's good), but where this long string is doesn't look right I would guess.

    If you'd like to email me your source: I'm dcarpene@opentext.com . I'll see if I can figure this out, assuming that's an option.

    @siegel: vi is an editor with two modes: one which destroys your input and the other which beeps at you

  • For reference to those that may be following along: the issue was that the longstring was defined inside the function, which isn't allowed. It needs to be defined outside the function & then referenced from within the function. For example:

    Bad:

            function x() 
                    String y = `longstring`
                    .doSomething(y)
            end
    

    Good:

            String y = `longstring`
    
            function x() 
                    .doSomething(.y)
            end
    


    @siegel: vi is an editor with two modes: one which destroys your input and the other which beeps at you

  • Thanks Dave! It works fine.

    But it looks a bit weird for me - why doesn't syntax allow to declare a LONGSTRING in a function.

    So I need to declare many LONGSTRING variables in my script since I have many functions there :)

  • That one I cannot answer myself - I'll check to see what info may exist.

    @siegel: vi is an editor with two modes: one which destroys your input and the other which beeps at you

  • Thanks Dave but don't worry too much. That was just my thoughts aloud :)