Add an eval function on Preprocessing Builtin functions

0 votes
asked Oct 21, 2020 in Wanted features by The-Lu (31,620 points)

Hello PlantUML team,

  • Could you add on Preprocessing Builtin functions an eval function?
    in order to Convert a String to an expression.

Like:

:%eval("1 + 2");


[See on PlantUML...]

Regards,
Th.

commented Jun 9 by The-Lu (31,620 points)

Hello PlantUML team,

Researching a workaround, to eval the string "1+2", I discover this solution:

@startuml
!procedure proc($arg)
  $arg
  :$r;
!end procedure

proc("!$r=1+2")
@enduml

Nevertheless, it is not direct: it needs that the preproc runs more one or more time... cheeky

Therefore with:

java -jar  plantuml.jar -preproc test_eval.pu

We obtains, test_eval.preproc:

@startuml

  !$r=1+2
  :$r;
@enduml

Then, we observe the expected result wink:

@PlantUML

  • Could you allow, directly, or by parameter, the preprocessor to run more than one time [ideally until preproc_output(+ 1) == preproc_output(n)]?

Thanks for your works,
Regards,
Th.

1 Answer

0 votes
answered Jun 24 by plantuml (257,940 points)
Very good idea!

You can now have http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuR9IJIrBpD5GCbJGLZ1IqhJciZAsvd98pKi1IW80

Is this what you were expecting ?
commented Jun 24 by The-Lu (31,620 points)

Hello,

Goods yes

Is it possible to eval also Builtin functions, as:

@startuml
:3;
:%eval("1+2");
:%version();
:%eval("%version()");
@enduml

Regards,
Th.

commented Jun 24 by The-Lu (31,620 points)

Hello PlantUML,

Here is another test:

@startuml
!$a=1 + abc
:1 + abc = $a;

:1 + abc = %eval("1 + abc");

!$b="1 + abc"
:$b = %eval($b);
@enduml

Could you have a look?

Regards,
Th.

...