How to use "newpage" within loops

0 votes
asked Dec 22, 2024 in Question / help by ksi

' Ten pages are expected but there are only two ?
@startuml

!$i=0
 !while $i<10
    class $i
    !$i = $i + 1
    newpage
!endwhile
@enduml

1 Answer

0 votes
answered Dec 23, 2024 by The-Lu (76,660 points)
 
Best answer

Hello K.,

  • What is your version?

FYI, I test locally with version 1.2024.8beta7 and all is good.

Here is the output of:

java -jar plantuml.jar -preproc myfile.puml

@startuml
    class 0
    newpage
    class 1
    newpage
    class 2
    newpage
    class 3
    newpage
    class 4
    newpage
    class 5
    newpage
    class 6
    newpage
    class 7
    newpage
    class 8
    newpage
    class 9
    newpage
@enduml

Regards,
Th.

commented Dec 24, 2024 by ksi
Hello Th,
my version is also 1.2024.8 and your preprocessor test command gives me the same output as well.
But the same test in VisualStudioCode (with PlantUML version 1.2024.8) produces only 2 pages. It seems that the loop is not recognized.
And in Eclipse there is the same behaviour. There are only 2 pages instead of 10 pages.
No clue why the IDEs behaves like that?
Regards,
ksi
commented Dec 24, 2024 by The-Lu (76,660 points)

Hi K.,

Thanks for your answer.

There is now an issue on the plugin side. 

Some plugins reinterpret preprocessor directives.... sad

Regards,
Th.

...