Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Great library! One question - How to get the result of tcl/tk function call #19

Open
john157157 opened this issue Feb 15, 2022 · 1 comment

Comments

@john157157
Copy link

Any time I try to get information from tcl/tk I do an Eval like this:

`
i := ir.Eval("[winfo screenheight .]")

fmt.Println(i)
`

and it produces a response like this:
invalid command name "1080"

Obviously tcl is trying to execute the result of the winfo call. Same thing happens with different functions and it doesn't matter if I put the results into a tcl variable first and then read the variable.

I can always strip the "invalid command name" and the quotes and have the result I need but that doesn't seem like the 'A' plan. Anybody know what I'm doing wrong?

Btw, I really am enjoying this library. Gothic and Golang templates go well together.

@john157157
Copy link
Author

john157157 commented Feb 19, 2022

It looks like setting a dummy variable and getting the result from one of the EvalAs() functions is the way it's done.

`
s, _ := ir.EvalAsString("set dummyvar [winfo screenheight .]")

Edit: (better answer)
s, _ := ir.EvalAsString("return [winfo screenheight .]")

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant