Please use our GitHub Issues page for all new support inquiries. If you need to contact us directly, please e-mail [email protected]

I'm trying to write a script that will create a new column (didchildhelp) by copying an existing column (task). The new cells will retain the onset/offset times of the original cells, and will have space for coding a yes/no arguement.

Here is my script:
task = getVariable("Task")
didchildhelp = createNewVariable("DidChildHelp", "yesno")
didchildhelpcell = didchildhelp.make new cell
didchildhelpcell.change arg("onset", taskcell.onset)
didchildhelpcell.change arg("offset", taskcell.offset)
setVariable("DidChildHelpcell", didchildhelpcell)

When trying to run the script in Datavyu, I receive the following error message:
NoMethodError: undefined method `getVariable' for main:Object
(root) at script:2
See line 2 of G:\DatavuHelpingScript.rb:
task = getVariable("Task")

Any advice on how to get things running smoothly?

asked 31 Oct '16, 14:16

ScriptingTrouble's gravatar image

accept rate: 0%

Depending on your version of Datavyu, you will need to explicitly load the Datavyu API library in your scripts. This can be done using the following line of code: require 'Datavyu_API.rb'. You will have to place this somewhere in your script before using any features that are part of the API and not part of core Ruby. I would recommend placing it at the top of your script before any other lines of code so you don't have to worry about it later on.

Additionally, you will have to modify the lines of code after creating the new column to create cells in the new column for each cell in the task column — currently taskcell is undefined so the script will crash when trying to change the onset time. You can do this by iterating over your task cells with the each function:

task.cells.each do |taskcell|
  didchildhelpcell = didchildhelp.make_new_cell() # your underscores may have been removed by the text formatter when you posted your question.
  didchildhelpcell.onset = taskcell.onset # your code does the same, this is just less to type
  didchildhelpcell.offset = taskcell.offset
end # this "end" is for the "do" keyword
end # this "end" is for the "begin" keyword

permanent link

answered 31 Oct '16, 15:06

Shohan%20Hasan's gravatar image

Shohan Hasan ♦♦
accept rate: 14%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 31 Oct '16, 14:16

question was seen: 4,052 times

last updated: 31 Oct '16, 15:06

powered by OSQA