help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting variables, argumunts in defun


From: Jean Louis
Subject: Re: Setting variables, argumunts in defun
Date: Sat, 13 Feb 2021 22:15:33 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* wael-zwaiter@gmx.com <wael-zwaiter@gmx.com> [2021-02-13 19:19]:
> I would like to set up devi and scal by selecting either one or
> the other.  Wow can I do this in elisp.  Should I pass parameters
> to the function.  Can one pass a string, then check its contents?
> 
> (defun deviscal ()
> 
>   (setq devi 0.18)
>   (setq scal 0.2)
> 
>   (setq devi 0.0)
>   (setq scal 1.0) )

I am trying to understand. How are you selecting either one or the
other?

What is devi? What is scal? Is that meaning something special?

If you mean to make a function to set variable devi or scal, you could
do maybe function like this:

(defun devi-scal (&optional devi-value scal-vale)
  (when devi
    (setq devi devi))
  (when scal
    (setq scal scal)))

But that implies that variables `devi' and `scal' are global and
you wish to set global variable.

Then you could use (devi-scal 0.18 nil) to set only variable
`devi' or (devi-cale nil 0.18) to set only variable `scal'
or (devi-scal 0.18 1.0) to set both of them.

Is that what you mean?

Jean



reply via email to

[Prev in Thread] Current Thread [Next in Thread]