another function question

papawo
papawo Member, Developers Posts: 206 PRO
edited March 2018 in FeatureScript
lets say a feature that gives 'data' whatever the user pick
line & line = data
plane = data

how to do an export function to get 'data' usable to other fs?

Tagged:

Answers

  • konstantin_shiriazdanov
    konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    if you mean that function should evaluate some query of unknown type and do some action with it then use the sequence of try silent {} operators

    function evQuery(context is Context, query is Query)
    {
    var result;
    try silent {
    result = evLine();
    debug(context, result);
    return result;
    }
    try silent {
    result = evPlane();
    debug(context, result);
    return result;
    }
    //and so on
    }


  • papawo
    papawo Member, Developers Posts: 206 PRO
    the whole feature does the evaluating already. and I would like to capture the result to be exported.
    when trying to do a function, I ending up repeating the code of the feature.
  • konstantin_shiriazdanov
    konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    then simply assign desired results of feature evaluation to the variable or append to array and do debug() or print() in the end
  • papawo
    papawo Member, Developers Posts: 206 PRO
    it does println or debug.
    how to do the variable or append? 
  • konstantin_shiriazdanov
    konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    ok, now i noticed your edited question.
    there are 2 ways to make data global:
    - setVariable() function creates global variable of any type (even function type) and this value can be obtained in later added features by getVariable()
    - setAttributes()/getAttributes() sets and gets attributes of any type to a certain geometry, which can later be extracted by other features