[solved] Problem to interpolate $ variables

Hi!

i wrote a funktion which creates a FvwmForm in a file to print out messages]DestroyFunc FuncShowMultipleMessages
AddToFunc FuncShowMultipleMessages

  • I Piperead ‘echo SetEnv MsgCount $1’
  • I Piperead echo 'DestroyModuleConfig FvwmForm-MultipleMessages: *' > ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo '*FvwmForm-MultipleMessages: WarpPointer' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo "*FvwmForm-MultipleMessages: Title \\"$0\\"" >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages
  • I Piperead start=1; MsgCount=$(($MsgCount+1)); while [ "$start" -lt "$MsgCount" ]; do \ echo '*FvwmForm-MultipleMessages: Line left' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo "*FvwmForm-MultipleMessages: Text \\"\\$MSG${start}\\"" >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ start=$(($start+1)); \ done
  • I Piperead echo '*FvwmForm-MultipleMessages: Line center' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo '*FvwmForm-MultipleMessages: Button quit \" Ok \"' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo '*FvwmForm-MultipleMessages: Command !(rm -f ${FVWM_USERDIR}/FvwmForm-MultipleMessages)' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages
  • I Schedule 100 Module FvwmForm FvwmForm-MultipleMessages “MSG1=$2” “MSG2=$3” “MSG3=$4” “MSG4=$5” “MSG5=$6” “MSG6=$7” “MSG7=$8” [/code]
    It will call e.g. over a key like this]key K A CM FuncShowMultipleMessages “Mouse Bindings for Titlebar” 7
    “Mouse 1: Drag moves window”
    " Maximize on double click"
    “Mouse 2: Drag moves window”
    " Raise or lower with click"
    “Mouse 3: WindowOps2 menu with click”
    " WindowsOps menu with ALT + click"
    “Mouse 4/5: Rolling wheel up/down shades/unshades”[/code]
    Now, I’ve more than 9 lines and I want to change echo "*FvwmForm-MultipleMessages: Text \\"\\$MSG${start}\\"" >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \
    respectively[code]
  • I Schedule 100 Module FvwmForm FvwmForm-MultipleMessages “MSG1=$2” “MSG2=$3” “MSG3=$4” “MSG4=$5” “MSG5=$6” “MSG6=$7” “MSG7=$8” “MSG8=$9”
    [/code]
    into echo "*FvwmForm-MultipleMessages: Text \\"$${start}\\"" >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \
    and[code]
  • I Schedule 100 Module FvwmForm FvwmForm-MultipleMessages
    [/code]
    but the invocation won’t work. I’ve tried several implementations with 2,3,4, $ signs, without the {}, with a [] but nothing works. I’ve searchd in the forum, red Fvwm manpages, but found nothing which worked as expected. The only thing I’ve got is the content of the start variable (1, 2, 3, … or ${start}) but not the content of $1, $2, $3, …

What do I wrong?

Thanks in advance,

Thomas

Hi,

after many tests with shell commands, FvwmPerl, FvwmConsole etc I found the solution :bulb:
Now the script can theoretically print n-messages 8)

There were several problems:

  1. $${start} is NOT a variable in a variable. Only e.g. “1” :confused:
  2. not all that works in a shell works with Piperead e.g. the shell construct ${!start} (variable in a variable)
  3. $[n-] works as $* in the shell - all of the parameters split in single words
  4. “$[n-]” and “$*” concatenate all parameters to one string
  5. spaces or tabs between parameters won’t work

Ok, here’s my new code

The function call]key K A CM FuncShowMultipleMessages “Mouse Bindings for Titlebar”
“Mouse 1: Drag moves window”
" Maximize on double click"
“Mouse 2: Drag moves window”
" Raise or lower with click"
“Mouse 3: WindowOps2 menu with click”
" WindowsOps menu with ALT + click"
“Mouse 4/5: Rolling wheel up/down shades/unshades”[/code]

The function itself]DestroyFunc FuncShowMultipleMessages
AddToFunc FuncShowMultipleMessages

  • I Piperead echo 'DestroyModuleConfig FvwmForm-MultipleMessages: *' > ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo '*FvwmForm-MultipleMessages: Font 8x13' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo '*FvwmForm-MultipleMessages: WarpPointer' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo "*FvwmForm-MultipleMessages: Title \\"$0\\"" >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages
  • I Piperead start=0; for i in $*; do \ if [ "$start" -gt "0" ]; then \ echo '*FvwmForm-MultipleMessages: Line left' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo "*FvwmForm-MultipleMessages: Text \\"$i\\"" >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ fi; \ start=$(($start+1)); \ done
  • I Piperead echo '*FvwmForm-MultipleMessages: Line center' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo '*FvwmForm-MultipleMessages: Button quit \" Ok \"' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages; \ echo '*FvwmForm-MultipleMessages: Command !(rm -f ${FVWM_USERDIR}/FvwmForm-MultipleMessages)' >> ${FVWM_USERDIR}/FvwmForm-MultipleMessages
  • I Schedule 100 Module FvwmForm FvwmForm-MultipleMessages[/code]

I hope these clarifys a little bit some mystifications about invocation in piperead …

cheers and happy easter :wink:,
Thomas :smiley: