Re: [O] Referring to an Org Babel variable in the invocation arguments to another Org Babel code block

2017-01-01 Thread Charles C. Berry

On Sun, 1 Jan 2017, Zack Piper wrote:


Hi Nicolas,
I tried "c", and it gives me:


c <<<


as the result.

I would like it to use the _variable_ "c", not the literal string.
So the result should be ">>> test <<<"



You mean you want to use the `name' of one `:var name=assign' argument
in the `assign' part of another --- something like what `let*' does in 
lisp.


But you simply cannot do that.

`(info "(org) var")' tells us what you can do:

#+BEGIN_QUOTE

The following syntax is used to pass arguments to `src' code blocks
using the `:var' header argument.

 :var name=assign

The `assign' is a literal value, such as a string `"string"', a number
`9', a reference to a table, a list, a literal example, another code
block (with or without arguments), or the results from evaluating a
code block.

#+END_QUOTE

The `name' of one argument is none of these (regardless of its effect when 
the body of the src block is executed, which BTW depends on the src block 
language).


There are other approaches that might serve a purpose in babel src blocks 
like that served by `let*' in lisp:


- putting variables in a table (possibly invoking `org-sbe' in a
 formula) and then referencing table cells

- writing other src blocks to handle the preliminary processing and
  referncing them

- writing an elisp src block that does those preliminaries (perhaps
  using `org-babel-ref-resolve' to call other src blocks), then builds
  a string specifying a call to your shell src block and calls it
  using `org-babel-ref-resolve'.

- using a noweb reference that executes another src block (or blocks).

- setting property values and referencing them

You might have better luck getting guidance on a useful approach by
trying to describe what you want to accomplish.


HTH,

Chuck



Re: [O] Referring to an Org Babel variable in the invocation arguments to another Org Babel code block

2017-01-01 Thread Zack Piper
Hi Nicolas,
I tried "c", and it gives me:

>>> c <<<

as the result.

I would like it to use the _variable_ "c", not the literal string.
So the result should be ">>> test <<<"

I've also cleaned up the Org I made (something went wrong when I pasted
it before, it missed an #+END_SRC)
Thanks!
#+NAME: block-1
#+BEGIN_SRC shell :var x="X"

echo ">>>" $x "<<<" #+END_SRC

#+END_SRC

#+BEGIN_SRC shell :var c="test" y=block-1("c")
echo $y
#+END_SRC

#+RESULTS:
: >>> c <<<

On 12/29/2016 03:49 PM, Nicolas Goaziou wrote:
>> #+NAME: block-1 #+BEGIN_SRC shell :var x="X" echo ">>>" $x "<<<"
>> #+END_SRC #+BEGIN_SRC shell :var c="test" y=block-1(c) echo $y
>> #+END_SRC #+RESULTS: : >>> $c <<< 



Re: [O] Referring to an Org Babel variable in the invocation arguments to another Org Babel code block

2016-12-29 Thread Nicolas Goaziou
Hello,

Zack Piper  writes:

> When I use your example, and adjust it slightly:
>
> #+NAME: block-1
> #+BEGIN_SRC shell :var x="X"
>
> echo ">>>" $x "<<<" #+END_SRC
>
> #+BEGIN_SRC shell :var c="test" y=block-1(c)
> echo $y
> #+END_SRC
>
> #+RESULTS:
> : >>> $c <<<

ITYM

  y=block-1("c")

Regards,

-- 
Nicolas Goaziou



Re: [O] Referring to an Org Babel variable in the invocation arguments to another Org Babel code block

2016-12-28 Thread Zack Piper
Hi all,

Still struggling with this, does anyone have any ideas?




Thanks!

-- 
Zack Piper  System administrator
https://apertron.net



Re: [O] Referring to an Org Babel variable in the invocation arguments to another Org Babel code block

2016-12-27 Thread Zack Piper
Hi Charles,

I think I found precisely the issue I'm having.

When I use your example, and adjust it slightly:


#+NAME: block-1
#+BEGIN_SRC shell :var x="X"
echo ">>>" $x "<<<"
#+END_SRC


#+BEGIN_SRC shell :var c="test" y=block-1(c)
echo $y
#+END_SRC

#+RESULTS:
: >>> $c <<<


I added a reference to an argument defined within the same block.

I get the aforementioned error:

org-babel-ref-resolve: Reference ā€˜cā€™ not found in this buffer

Thanks!
Zack



Re: [O] Referring to an Org Babel variable in the invocation arguments to another Org Babel code block

2016-12-27 Thread Charles C. Berry

On Tue, 27 Dec 2016, Zack Piper wrote:


Hi all,

Hopefully the below can explain better:


[deleted]

This is a workable idiom. C-c C-c on the second block produces the
output shown.


#+NAME: block-1
#+BEGIN_SRC shell :var x="X" 
echo ">>>" $x "<<<"

#+END_SRC


#+BEGIN_SRC shell :var y=block-1("input to this block")
echo $y
#+END_SRC

#+RESULTS:
: >>> input to this block <<<

HTH,

Chuck




[O] Referring to an Org Babel variable in the invocation arguments to another Org Babel code block

2016-12-27 Thread Zack Piper
Hi all,

Hopefully the below can explain better:

#+NAME: abc
#+BEGIN_SRC shell :noweb yes :var a="b" :results output
echo <>
1
EOF
#+END_SRC

#+RESULTS: def
: 


Pressing `C-c C-c' on the second block returns:


org-babel-ref-resolve: Reference ā€˜cā€™ not found in this buffer


Org version: 9.0.3


Thanks!

-- 
Zack Piper  System administrator
https://apertron.net