Internal variable

Hello,

I have a problem for using a fvwm variable.

Here is my functions:

AddToFunc essai

  • “I” GotoDesk 0 $0
  • “I” PipeRead ‘echo sendToModule FvwmButtons ChangeButton DeskName Title “$”[desk.name$0]’

This function works BUT have to I use a piperead because this one doesn’t work

AddToFunc essai

  • “I” GotoDesk 0 $0
  • “I” sendToModule FvwmButtons ChangeButton DeskName Title $[desk.name$0]’

How to use argument in $[desk.name] variable?

Damien

Firstly, some points…

  1. The use of quoting, as in:
  • “I” …

is now no longer needed. You can just use:

  • I …

Secondly, you don’t need to quote the “$” sign when you use variable interpolation:

$[desk.n$0]

is sufficient.

The reason why the second function fails, is because FVWM needs to interpolate (that means ‘expand’) the variable, which can only be done via the shell – that’s what piperead is doing here, and returning the entire result back to FVWM.

– Thomas Adam

However, it doesn’work.

I have to qote the $.

Here is the error message

sh: line 1: desk.namesh: syntax error in expression (error token is “.namesh”)

The problem come from the shell

Dollar are interpreted by the shell. Dollar must bo quoted …

  • I PipeRead ‘echo sendToModule FvwmButtons ChangeButton DeskName Title “$”[desk.name$0]’

The first dollar must be quoted, not the second …

Here are results of my investigation:

Functions that work:

AddToFunc MakeDeskMenu1

  • “I” DestroyMenu recreate SendToDesk
  • “I” AddToMenu SendToDesk
  • “I” PipeRead ‘for i in 0 1 2; do
    if [ $[desk.n] -ne $i ];
    then echo AddToMenu SendToDesk [color=blue]\[/color]$[desk.name$i] ChangeDesk1 $i;
    fi; done;’

AddToFunc ChangeDesk

  • I GotoDesk 0 $0
  • I PipeRead ‘echo SendToModule FvwmButtons ChangeButton DeskName Title [color=blue]"$"[/color][desk.name$0]’

AddToFunc ChangeDesk1

  • “I” MoveToDesk 0 $0

  • “I” PipeRead ‘echo SendToModule FvwmButtons ChangeButton DeskName Title [color=blue]\[/color]$[color=blue]\[/color][desk.name$0[color=blue]\[/color]]’

  • “I” GotoDesk 0 $0

  • “I” WarpToWindow 0 0

Functions that don’t work:

AddToFunc ChangeDesk

  • I GotoDesk 0 $0
  • I PipeRead ‘echo SendToModule FvwmButtons ChangeButton DeskName Title $[desk.name$0]’

AddToFunc ChangeDesk1

  • “I” MoveToDesk 0 $0
  • “I” PipeRead ‘echo SendToModule FvwmButtons ChangeButton DeskName Title [color=blue]\[/color]$[desk.name$0]’
  • “I” GotoDesk 0 $0
  • “I” WarpToWindow 0 0

AddToFunc MakeDeskMenu1

  • “I” DestroyMenu recreate SendToDesk
  • “I” AddToMenu SendToDesk
  • “I” PipeRead ‘for i in 0 1 2; do
    if [ $[desk.n] -ne $i ];
    then echo AddToMenu SendToDesk $[desk.name$i] ChangeDesk1 $i;
    fi; done;’

Damien

(Apologies for the delay on this.)

Basically, what you’re seeing is an issue of interpolation. In a function such as yours where you have more than one operand working:

 All (foo) PipeRead '... $$[variable] ...'

(as a general example) – there’s often a need to make sure that variable interpolation happens at the right time. So you double-up on dollar signs and the like. Look at some of the other functions posted under this section, for further examples.

– Thomas Adam