Re: FVWM: Arithmetics?

From: Mikhael Goikhman <migo_at_homemail.com>
Date: Tue, 22 Apr 2003 03:14:23 +0000

On 21 Apr 2003 17:57:27 +0200, Felix E. Klee wrote:
>
> On Monday 21 April 2003 14:17, Mikhael Goikhman wrote:
> > > What you showed is preprocessing. As said in my original post, what
> > > I'm after is realtime processing where I need several global variables
> > > anyways. Concerning readability: I'm not a Perler and for me the code
> > > isn't very readable at all. Many FVWM users probably prefer a solution
> > > where they can do simple arithmetics without knowing Perl.
> >
> > Your original message was about the native support of arithmetics
> > (does this include scripting and string manipulation or just 2+2?).
>
> Just 2+2, etc.. It's probably not neccessary to include native
> arithmetics since it can easily be done using 3rd party tools. But if
> there is a lot of demand I guess it might be easy to add a simple Let
> command (I'm sure there are several small C libraries around that allow
> the avaluation of simple C like arithmetic expressions). OTOH such a
> command can also be easily forged by using Perl or other tools, maybe
> an example should be added to the FAQ.

Ok, here is a solution that makes your suggested function Let (that sets
environment variable) redundant. I call the function "." for compactness.
You may do 2+2 inside the command without temporary environment variables.

  AddToFunc .
  I SendToModule FvwmPerl preprocess -c -- $*

  . Exec exec xmessage %{2 + 2}%

  . GotoDesk 0 %{ $[desk.n] + 1 }%

  Next (MyWindow) . Move \
    %{($WIDTH - $[w.width]) / 2}%p %{($HEIGHT - $[w.height]) / 2}%p

The first example opens a "4" window, the second goes to the next desk.
The last example centers the given window, it should work in theory, but
it does not currently in cvs (should investigate why, probably a bug with
window contexts somewhere), here is a workaround for this using WindowId:

  Next (MyWindow) . WindowId $[w.id] Move \
    %{($WIDTH - $[w.width]) / 2}%p %{($HEIGHT - $[w.height]) / 2}%p

More examples that use some perl, not just arithmetics:

  . Exec exec xterm -name xterm-%{++$i}%
  . Exec exec %{ -x "/usr/bin/X11/aterm" ? "aterm" : "xterm" }% -sb

If this helps, I may put this in FAQ.

The function above only works in the current cvs, there was one problem.
If you want to use this with 2.5.2+ versions instead of cvs, then the "."
function above should be defined as the following instead:

  DestroyFunc .
  AddToFunc .
  + I SendToModule FvwmPerl eval preprocess({ 'command' => 1 } , q<$*>)

Regards,
Mikhael.
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Mon Apr 21 2003 - 22:16:10 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:54 BST