Announcing the new Datavyu v1.3.6 with enhanced features and transcription support!

Hello,
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:
begin
task = getVariable("Task")
didchildhelp = createNewVariable("DidChildHelp", "yesno")
didchildhelpcell = didchildhelp.make new cell
didchildhelpcell.change arg("onset", taskcell.onset)
didchildhelpcell.change arg("offset", taskcell.offset)
end
setVariable("DidChildHelpcell", didchildhelpcell)
End

When trying to run the script in Datavyu, I receive the following error message:
SCRIPT ERROR
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

ScriptingTro...
11112
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 ♦♦
24115
accept rate: 11%

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×42
×2
×1
×1

question asked: 31 Oct '16, 14:16

question was seen: 496 times

last updated: 31 Oct '16, 15:06

powered by OSQA