Skip to content

(JS) How to set list value from file? #427

Answered by GarboMuffin
piw-piw asked this question in Q&A
Discussion options

You must be logged in to vote

most easily you just use right click -> import/export on a list watcher. If that doesn't work for you:

How to set list value from file in project folder?

fetch("file.txt")
  .then(r => r.text())
  .then(text => {
    vm.runtime.getTargetForStage().lookupVariableByNameAndType("list name", "list").value = text.split("\n");
  })

And vice versa?

You can get the list data from vm.runtime.getTargetForStage().lookupVariableByNameAndType("list name", "list").value and convert that to a string to download to your computer.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by piw-piw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants