Home AMX User Forum NetLinx Studio

Return Char string from Function?

The NetLinx Help manual states, "the return type cannot be a structure or a class". Does this mean that a NetLinx function cannot handle a CHAR type larger than 1? It appears so because I get a compile error for this:
DEFINE_FUNCTION CHAR playinginroom[20] (INTEGER this_device[]) {

Of course it compiles fine if I leave off the square brackets from the function name, but then I don't get anything returned from the function:
DEFINE_FUNCTION CHAR playinginroom (INTEGER this_device[]) { 
   STACK_VAR this_text[20]
   this_text = "'AB,C,DE,GR'" //Actually a stack of code that produces this result
   SEND_STRING debug,"'Text Returned from Function: ',this_text" //Shows AB,C,DE,GR
   RETURN this_text
}

When I use this function elsewhere in my code, I get nothing returned from it. Can someone tell me whether or not this *should* work or not? Will I have to change this into a DEFINE_CALL to get text from it?

Thanks,

Comments

  • The Function has do be defined:
    DEFINE_FUNCTION CHAR[20] playinginroom(INTEGER this_device[])
    

    That's it.
  • [QUOTE=Marc Scheibein
    DEFINE_FUNCTION CHAR[20] playinginroom(INTEGER this_device[])
    
    [/QUOTE]

    Ah - thanks for the quick reply! That worked, I was just making a stupid syntax error.
  • DHawthorneDHawthorne Posts: 4,584
    It's not like that error message helped ... but it thought you were trying to return a custom structure type by the way it was worded.
  • That's just me still being relatively new to AMX. Everywhere else I define a char, it goes CHAR varname[size]. This is the first time I've needed a function that returns a CHAR value, so I didn't realize the syntax was different: CHAR[size] functionname(). The Help files in NetLinx studio don't have any samples or adequate explanation of defining CHAR-based functions.

    I really do appreciate getting the tip on the correct syntax so quickly on this forum. Thanks Marc!
Sign In or Register to comment.