Doing arithmetics with variables

Is there any way to calculate values from variables? I’d like to do something like $[screen_width] - 64, $[screen_height/2, etc. You get my drift.

Or do I have to make that a feature request?

[color=red]Edited by theBlackDragon:
–> Moved from FvwmScript[/color]

If this is truly a FvwmScript question, look at the documentation. There are add, multiply, divide, etc functions.

If this isn’t a FvwmScript question, you have to use PipeRead to accomplish that.

Oops, it’s not FvwmScript, I admit to not having known what FvwmScript actually is :blush:

Anyway, the question stands. I am confused by variable names, brackets and how they are passed to the shell in a PipeRead. Would SetEnv y PipeRead "echo $[2*$[x]]" set $[y] to 2*$[x]?

It’s a way of creating little GUIs.

You’re confused by the shell more like. The PipeRead command does nothing more than evaluate things at the shell and sends (‘‘echo’’) back the result to FVWM for it to understand and process. Where you have (in the above):

SetEnv y PipeRead "echo $[2*$[x]]"

Is not quite right. What FVWM will try and do there is to set the value of ‘y’ to not a lot. Because you’re evaluating things in a PipeRead – everything has to be in it. Hence:

PipeRead 'echo SetEnv y $((2*$[y]))'

… is probably more like what you’re after. Note what is happening. As soon as you enter into the PipeRead, you’re at the shell. The ‘‘echo’’ statement is sending the result of what is about to be interpolated, to FVWM. So the shell will work out the calculation in the brackets “$((2*$[y]))”, then send back:

SetEnv y <result>

Does that clear things up?

– Thomas Adam

Gotcha.

Thanks!