I want to simplify the definition of (customer specific) procedures/functions in the C4 model.
And my idea was to write a function which defines the new functions/procedures into a string and then include the string like a file. My first idea (without the !includestring) was that I write it directly into the file but this produces a syntax error like below
@startuml
!unquoted function Call($from, $to, $text = "calls")
!$sq="'"
!$dq='"'
!$def = '[' + $dq + $from + $dq +']->[' +$dq + $to + $dq + '] :' + $dq + $text + $dq
!return $def
!endfunction
Call(a 1, b 1)
!unquoted function $defineCall2($newDefault)
!$sq="'"
!$dq='"'
!$def = '!unquoted procedure Call2($from, $to, $text = ' + $dq + $newDefault + $dq + ')' + %newline()
!$def = $def + '[' + $dq + '$from' + $dq +']->[' +$dq + '$to' + $dq + '] :' + $dq + '$text' + $dq + %newline()
!$def = $def + '!endprocedure' + %newline()
!return $def
!endfunction
$defineCall2("is called via message")
' with following include call, could it work
' !includestring $defineCall2("is called via message")
Call2(c 1, d 1)
@enduml

Atm. I could only create via a `-preproc` command an intermediate file and in a second call create the final diagram.
@startuml
["a 1"]->["b 1"] :"calls"
!unquoted procedure Call2($from, $to, $text = "is called via message")
["$from"]->["$to"] :"$text"
!endprocedure
Call2(c 1, d 1)
@enduml
With `!includestring $defineCall2("is called via message")` dynamic macros would be possible.
Thank you and best regards
Helmut