Skip to content

how to execute a function with no return value #634

Answered by antonmedv
carmel asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, right now, it is not possible to do that. As Expr is only for expressions, and all expressions should return a value.

You can work around this restriction by returning something from functions and discarding the results. For example return true and you can this:

let para = AddParagraph();
let run = para.AddRun();
run.AddText("document title")
and SaveToFile("test.docx")

Or wrap in array:

[
     run.AddText("document title"),
     and SaveToFile("test.docx"),
]

I'm thinking to add an option to allow calling functions as statements. Also, I'm thinking of adding if/else into the language to the already existing cond ? yes : no.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@carmel
Comment options

Answer selected by carmel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants