Dror
Dror

Reputation: 13081

Pass string argument to a code block from a table in org mode

I'm trying to pass a string as the argument of a code block when using org-mode and org-babel. In particular, I consider the following minimal example:

#+NAME: test
#+BEGIN_SRC python :var x="foobar"
return len(x)
#+END_SRC

| 6 | #ERROR |
#+TBLFM: @1$1='(org-sbe test)::@1$2='(org-sbe test (x ("fb")))

As you can note, the first cell is filled correctly. However, I cannot make the second one be processed correctly. I tried various options; for example:

#+TBLFM: @1$1='(org-sbe test)::@1$2='(org-sbe test (x "fb"))
#+TBLFM: @1$1='(org-sbe test)::@1$2='(org-sbe test(x="fb"))

Any ideas?

BTW: #+CALL: test(x="fb") returns the expected result, i.e. 2. It seems like the syntax for inline calling or "table-calling" is different... :(

Upvotes: 3

Views: 830

Answers (1)

Dror
Dror

Reputation: 13081

Finally found the right combination!

| 6 | 3 |
#+TBLFM: @1$1='(org-sbe test)::@1$2='(org-sbe test (x \"bar\"))

Note that the " have to be escaped...

Upvotes: 4

Related Questions