Menu

Multi line SET statement

2013-11-06
2013-11-07
  • Ulf Pettersson

    Ulf Pettersson - 2013-11-06

    I cant find a practical way to extend a muti-variable assignment across multiple
    code line.

    This is needed when there are many values to assign (that cant fit on one line) or
    when assignment need to be done in a loop or in in separate statements.

    A few possible approaches are:

    #set myMultiVariable = "Value1", "Value2", "Value3", "Value4"
    #set myMultiVariable = ?@myMultiVariable?, "Value5", "Value6", "Value7", "Value8"

    or

    #set myMultiVariable = "Value1", "Value2", "Value3", "Value4"
    #set myMultiVariable = myMultiVariable + "Value5", "Value6", "Value7", "Value8"

    or

    #set myMultiVariable = "Value1", "Value2", "Value3", "Value4",
    #set myMultiVariable += "Value5", "Value6", "Value7", "Value8"

    If I recall correct, I used the first of the above when using XVCL.

     
  • Daniel Dan

    Daniel Dan - 2013-11-07

    Dear Ulf,

    I think it wouldn't be a problem to add the ability to continue a #set command in the next line, which would mean having a #set command in multiple lines.

    For extension of a variable:
    I would also suggest the first option given. You recall correctly, I tried these things in XVCL.

    So

    #set myMultiVariable = "Value1", "Value2", "Value3", "Value4"
    #set myMultiVariable = ?@myMultiVariable?, "Value5", "Value6", "Value7", "Value8"
    

    Will result a multi-variable having values: "Value1", "Value2", "Value3", "Value4", "Value5", "Value6", "Value7", "Value8"

    However we have to forbid extension of a variable, which is a control variable of any currently processed loop, since that would be unsafe and could lead to errors.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.