# Copying a reporters result to the clipboard

I'm working on past Advent of Code puzzles to warm myself up for this year's and I wanted to copy a result to the clipboard so I could paste it into the AOC website.

But I can't see an easy way to do it

Am I missing something simple or is the facility missing?

I came up with this method

and then selecting the value in list block and using ctrl-C on it

but its a big sledgehammer for a little job

you can use this block, but in order to copy a list, you need to do something like

[scratchblocks]
wait until(call (JSFunction [data] [let res = null; navigator.clipboard.writeText(data.toString()).then(_ => { res = data; ).catch(err => {throw err;}); return () => res;] :: operators) with inputs [what you need to copy]:: control
[/scratchblocks]

we can't see the whole code.

Not the same code, but this one would work: (takes a parameter data) const d = typeof data === 'string' ? data : JSON.stringify(data, null, 2); navigator.clipboard.writeText(d); note that running multiple times doesn't guarantee the first one is done before the second runs.

The problem is that navigator.clipboard.writeText is asynchronous, and you need to wait for the returned promise to resolve before doing the next action.

The best solution would be js function blocks to be async/awaitable