How to read interactively on two inputs and use them in a function call

I am currently taking a class to learn elisp, so I have no experience with this language. I am trying to read two inputs interactively (width and length of a rectangle) and then use them to call a function to calculate the area of ​​the rectangle. The code I have is as follows:

(defun rectangle_Area(wl) "Compute the area of a rectangle, given its width and length interactively." (interactive "nWidth: ") (interactive "nLength: ") (setq area (rectangleArea wl)) (message "The rectangle area is %f." area)) 

I am currently mistaken in the error of the number of arguments. As I said, I have no previous experience ... I really need to know how to store / read in two separate values ​​using interactive ones.

Thanks for any help

+7
source share
1 answer

Ch f interactive RET :

To get multiple arguments, concatenate the individual lines, separating them with newline characters.

So we have:

 (defun rectangle_Area(wl) "Compute the area of a rectangle, given its width and length interactively." (interactive "nWidth: \nnLength: ") (setq area (rectangleArea wl)) (message "The rectangle area is %f." area)) 
+8
source

All Articles