Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

M

mmladinov

@mmladinov
Unfollow Follow
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Returning array from custom function in NXSL
    M mmladinov
    Support

    @victor said in Returning array from custom function in NXSL:

    Hi,

    dot (.) is a string concatenation operation, so line

    data=cfunctions.getToken(data);

    concatenates value of variable cfunctions (likely null) with returned array, which resulted in a null converted to string concatenated with array converted to string.

    Best regards,
    Victor

    It all makes sense now. So easy when master explains it. 🙂

    Thank you.


  • Returning array from custom function in NXSL
    M mmladinov
    Support

    @tomaskir said in Returning array from custom function in NXSL:

    Can you replicate the problem in a simple to use function?

    [snip]

    So it sounds like your problem is somewhere else.

    Thank you for your reply. You are right. I tried your suggestion of simple function and it worked, so I tracked the problem to calling my function by library_name.function_name(), instead of just function_name().

    I don't know if this other syntax of calling ( lib.fn() ) should work or not. I mean, in my code, the correct function was called even with lib.fn() syntax, and it did it's job, just the returning of an array was a problem. (I tested returning just a string and that worked fine).

    Do you think this was just mistake in my code and it half-worked by accident, or is this a bug and I should report it somewhere? Anyway, thank you for your help.


  • Returning array from custom function in NXSL
    M mmladinov
    Support

    Hi. I'm new to NetXMS and I'm loving it - it's great.
    I'm using ver 2.0.2, and I'm trying to write function for a common task in script library which should return array. However returned value is string with text that looks like it is reference to the array or similar. So I have in one script library called cfunctions:

    sub getToken(data) {
    text=data[1];
    delimiter=data[2];
    position=data[3];
    i=index(text,delimiter,position);
    if (i==0) {
    token=substr(text,position);
    position=null;
    } else {
    token=substr(text,position,i-position);
    position=i+1;
    }
    return %(text,delimiter,position,token);
    }
    

    then in another script i have:

    use cfunctions;
    t="aa,bb,cc,dd";
    delimiter=",";
    position=1;
    array data;
    data[1]=text;
    data[2]=delimiter;
    data[3]=position;
    data[4]="";1
    
    data=cfunctions.getToken(data);
    ...
    

    If I try to use data[1] after call to my function I get error that object is not a container, if I print typeof(data) I get that it is string, and if I print variable data  I get someting like: [A@0x7ff74c30c9f9].

    I also tried to create array in getToken function and populate it one by one (array retr; retr[1]=..., retr[2], .... return retr;) but I get same problem.

    So how can I return and use returned array from my function.

    Thank you.

  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups