Announcement

Collapse
No announcement yet.

Parameter loses comas when edited

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parameter loses comas when edited

    I have this EFS:

    PHP Code:
    function preMain() {
        
    _init true;
        var 
    x=0;
        
    aFPArray[x] = new FunctionParameter"p1"FunctionParameter.STRING);
        
    withaFPArray[x++] ) {
            
    setDefault"1,2,3" );
        }
    }

    var 
    aFPArray = new Array();
    var 
    _init;

    function 
    main(p1) {
        if(
    _init) {
            
    debugPrintln(p1);
            
    _init false;
        }

        return;

    The output window shows 1,2,3 (as expected) when loaded.

    However, if I edit the study properties and in the Value field for the p1 param I type 1,2,3 then the output window shows 123. i.e. comas missing.

    Any ideas anyone?
    Standing on the shoulders of giants.

  • #2
    wildfiction
    I believe that what you are seeing is due to string concatenation. In JavaScript you can concatenate multiple strings by separating them with a comma ie "1,2,3" instead of doing "1"+"2"+"3"
    One solution is to enclose the parameter in quotes (single or double) ie "1,2,3" and then use eval() on the variable. Alternatively you could use a different separator such as for example a pipe |
    Alex

    Comment


    • #3
      Thanks for your reply Alexis.

      Why do you think that this is not a problem on the initial load of the EFS and only when the parameter is edited?
      Standing on the shoulders of giants.

      Comment


      • #4
        wildfiction
        I am not sure but that may be because the default includes the quotes.
        Alex

        Comment

        Working...
        X