Error when returning the result of a user-defined function in basic

I have a LO Basic function whose job is to collect a string from the user and then return it with a newline appended. This is it:

Function ReportGen_GenNotes() as string
	dim iResponse as Integer
	dim strNotes as String
	
	iResponse = MsgBox("Are there special notes that need to be added to this report?", 4, "Special Notes?")
	If iResponse = 6 Then 'The user clicked Yes.'
		strNotes = inputBox("Enter the special notes as they should appear, including punctuation:", "Special Notes")

	END IF
	
	ReportGen_GenNotes = strNotes & char(&h0a)

End Function

When it runs, the last line before End Function yields

BASIC runtime error.
Sub-procedure or function procedure not defined.

What is wrong with that line?

Char() ?

May be Chr(10) ?

How do you use this function? Where you call it from?

Can you upload an ODF type sample file here with the embedded macro code?

It’s called by a macro, in order to put the appended string into a string variable in said macro so it can be added at a cursor in a document.

(BTW)
The correct way to insert hard line breaks, paragraph breaks, and a few more specialties into a text is decribed here:
(LibreOffice: XSimpleText Interface Reference)

The name User-Defined-Function is exclusive for Functions which are called via calc-formulas

Thanks! insertControlCharacter may be the more canonical approach than putting that character into a string and simply inserting that string, but in my situation, simply changing char(10) to chr(10) solved the problem, as sokol92 suggested.

Thanks for clarifying that. So, what does one call a function defined by the user to call via a macro?

function …simply function :wink:

thanks…simply thanks :wink: