You need to put the literal value of the argument inline in the
CALL. For example:
#+BEGIN_SRC elisp :var var1="val1"
(format "%s" var1)
fun2 fails because the
HEADER line cannot be applied to
CALL. Instead, you have to use a
CALL: <name>[<inside header arguments>](<arguments>)[<end header arguments>] syntax (see org manual), as in this example:
#+CALL: fun1[:var var1="val4"]()
fun3 fails because you can't refer back to values of previous variables defined in the same
:var header argument. The complete syntax for
:var is described in the relevant section of the org manual
Update: Responding to your edit and clarification, I do not think this is possible using the CALL syntax, which is relatively inflexible. However, with lisp functions we can construct a string representation of the nested source block call, and then use
org-babel-ref-resolve to do the equivalent of the CALL line.
For example, I define a source block
funX to be the basic building block (this function can be any in any language supported by babel).
#+BEGIN_SRC elisp :var a="A" s="X"
(format "%s.%s.%s" a s a)
Then, I have a lisp source block with a single parameter
s, which constructs a deeply nested call to the
funX block, with
s inserted as a parameter to the innermost function:
#+BEGIN_SRC emacs-lisp :var s="\" ¡Hola! \""
(defun funX (a s) (format "funX(\"%s\", %s)" a s))
(defun nested-funX (s)
(funX "a" (funX "b" (funX "c" (funX "d" (funX "e" s))))))
(org-babel-ref-resolve (nested-funX s))
: a.b.c.d.e. ¡Hola! .e.d.c.b.a
We can then re-use that source block in a CALL line with a different value of
#+CALL: funABCDE("\" Nǐ hǎo! \"")
: a.b.c.d.e. Nǐ hǎo! .e.d.c.b.a
Unfortunately, it is necessary to use an extra pair of escaped quotation marks in the argument for this to work.