On Tue, Jun 29, 2004 at 02:35:05AM -0500, Rusty Phillips wrote:
> Creating constant valued scalar variables is obviously possible with
> SetEnv, but is there an accepted way to do anything beyond this?
> I have two questions about this:
>
> I Lets say, for example, that I wanted to create a command that keeps
> track of the location of every window on the screen and restores them to
> that condition if I press that command again, while ignoring windows
> that are new or closed. Is this possible in fvwm?
>
> These are the big problems I can't solve:
> 1) I can't find a non-scalar assignment mechanism.
Fvwm does not support array variables directly. However, you can
put the array index in the variable name. For example:
setenv xpos_$[w.id] $[w.x]
setenv ypos_$[w.id] $[w.y]
(replace $[w.id] with $w for older fvwm versions). If you have
the window selected, you can access the stored property like this
by using the functions below:
array_get xpos $[w.id]
array_get ypos $[w.id]
# return values are now stored in xpos_val and ypos_val
With the functions array_init, array_append and array_delete you
can even manage indexed arrays. E.g.:
# create new array
array_init foo
# append a couple of entries
array_append foo entry1
array_append foo entry2
array_append foo entry3
# print some entries
array_get foo 1
echo $[foo_0] $[foo_val]
# delete entry2
array_delete foo 1
# clean out whole array
array_init foo
Looping over all aray indices can be done with a shell script via
piperead.
------------------------- snip -------------------------------------
#
# Fvwm based array implementation
#
# Warning: These function can *not* handle quoting characters or
# shell meta characters in variable names or contents.
# $0 = array name
# $1 = array index
# result is stored in $0_val
AddToFunc array_get
+ i piperead 'echo setenv \\"$0_val\\" \\"\\$\[$0_$1\]\\"'
# $0 = array name
AddToFunc array_init
+ I setenv "$0_num" 0
# $0 = array name
# $1 = data to store
AddToFunc array_append
+ i piperead 'echo setenv \\"$0_"\\$\[$0_num\]"\\" \\"\\$1\\"'
+ i piperead 'echo setenv \\"$0_num\\" \$\[$0_num + 1\]'
# $0 = array name
# $1 = array index to delete
# Note: If the array is already empty, this function may corrupt
# the array. The last entry in the array is moved to the vacant
# slot.
AddToFunc array_delete
+ i piperead 'echo setenv \\"$0_num\\" \$\[$0_num - 1\]'
+ i piperead 'echo setenv \\"$0_$1\\" \\"\\$\[$0_\${$0_num}\]\\"'
--------------------------------------------------------------------
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt, dominik.vogt_at_gmx.de
Reply-To: dominik.vogt_at_gmx.de
--
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.
- application/pgp-signature attachment: stored
Received on Tue Jun 29 2004 - 06:47:16 BST