gobravedave / Enterprise-Architect

scripts and other code snippets to extend Sparxs Enterprise Architect
BSD 2-Clause "Simplified" License
51 stars 12 forks source link

I want to be able to use note. #13

Closed Takashi-K-TakaTech closed 1 year ago

Takashi-K-TakaTech commented 2 years ago

The layout setting for note is difficult to understand. However, the following modification may enable note insertion. PlantUML test source:

@startuml
src ->> target : cmd1
note left : test abc
target -->> src : response
note right
test def
test ghi
end note
@enduml

Create-Sequence-Diagram modification code:

sub process_note(script)
dim i
dim LOGLEVEL_SAVE   '
LOGLEVEL_SAVE = LOGLEVEL
'LOGLEVEL=4 

    call LOGTrace("process_note (" & script & ")") 

    if ucase(script) = "END NOTE" then
        'add note element
        call add_note()
        multiline_note = False  'switch off multi line note indictor
    else
        if multiline_note = True then
            call contsruct_note(script)
        else    
            i = inStr(script, ":")
            'call LOGDebug( "offset for : = " & i & " of " & len(script))
            'plantuml doesnot recognise note:.. so assume anything after note and before the colon controls layout
            if i > 0 then                               'single line note
                noteName = Mid(script, i+1, 5)
                'call LOGDebug( "noteName : = " & noteName)
                call contsruct_note(right(script, len(script)-i))
                call add_note()
            else
                multiline_note = True
                noteName = "@GetNoteNameOfNextLine@"
                note=""
            end if
        end if
    end if
    call LOGTrace("multiline_note=" & multiline_note )
    'restore logging level  '
    LOGLEVEL=LOGLEVEL_SAVE      '

end sub

sub contsruct_note(script)
dim notes
dim i

    call LOGTrace("construct_note (" & script & ")") 

    notes = split(script, "\n")

    for i = 0 to ubound(notes)
        if note = "" then
            note = notes(0)
                ' set noteName at second line.
            if multiline_note = True And _
               noteName = "@GetNoteNameOfNextLine@" then
                noteName = Mid(note, 1, 5)
            end if
        else
            note = note & vbcrlf & notes(i)
        end if
        n=n+1
    next
    'call LOGDebug( "note* (" & note & ":" & n & ")")

end sub
gobravedave commented 1 year ago

Hi @Takashi-K-TakaTech I was not able to get your code to work.. I did however make some changes.. and the following now works..

@startuml
Alice->Bob : hello
note left: this is a first note

Bob->Alice : ok
note right: this is another note

Bob->Bob : I am thinking
note left of Bob
a note
can also be defined
on several lines
end note
@endum

Note Left: will place the note left of the first time line Note Right: will place the note right of the last time line

i hope this helps.. thanks, David.