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

Hey everyone,

I am trying to create a print script, and I'm receiving the following message:

** SCRIPT ERRROR ** @Line -1:'org.jruby.exceptions.RaiseException: undefined method `cells' for 6:Fixnum'

Does anyone know what the error means? The script is attached below:

begin id.cells.each do |idcell| foot.cells.each do |footcell| sidepref.cells.each do |sideprefcell| limb.cells.each do |limbcell|

            # Set up our conditional statements for what we want to print
              if idcell.onset <= footcell.onset and idcell.offset >= footcell.offset
                    if footcell.onset == sideprefcell.onset
                        if sideprefcell.onset == limbcell.onset

                              #subj study sex age walkexp crawlexp coder relcoder 
                              #trial# loc frststep reach nets change handnets restart reachand footonset footoffset 
                              #limb sideoffset

                              # Print ID
                            print idcell.subj + "\t" + idcell.study + "\t" + idcell.sex + "\t" + idcell.age + "\t" + idcell.walkexp + "\t" + idcell.crawlexp 
                                                                      + "\t" + idcell.coder + "\t" + idcell.relcoder + "\t"

                            # Print foot.  Note how all non-alphanumeric characters are stripped out.
                    print footcell.trial# + "\t" + footcell.1ststep + "\t" + footcell.reach + "\t"+ footcell.nets + "\t"+ footcell.change + "\t"

                            # Print sidepref    
                    print sideprefcell.handnets + "\t"  + sideprefcell.restart + "\t" + sideprefcell.reachhand + "\t" + footcell.onset.to_s + "\t" + footcell.offset.to_s + "\t"  + sideprefcell.offset.to_s + "\t"

                              # Print limb
                    print limbcell.limb + "\t"

                 end

end end end end end end end

asked 08 Mar '12, 01:13

jen_ducz's gravatar image

jen_ducz
1334
accept rate: 0%


It looks like you never used "getVariable" to access id, foot, sidepref, and limb from the openSHAPA file.

after begin, you should add these lines (assuming those are the variable names in OpenSHAPA):

id = getVariable("id")
foot = getVariaible("foot")
sidepref = getVariable("sidepref")
limb = getVariable("limb")

That will let you access each of the OpenSHAPA variables as ruby objects. Your script is crashing at the call of id.cells because id hasn't been defined as an openSHAPA variable.

Just to make sure, this script is at the end of the OpenSHAPA API, right? Let me know if this helps.

John

permanent link

answered 08 Mar '12, 03:23

JohnFranchak's gravatar image

JohnFranchak ♦
3964410
accept rate: 17%

What is the line "def get_ordinal(var)" doing after begin? I'm worried that maybe your script is being interpreted as a function definition. It should throw and error when it gets to getVariaible("foot") because of the typo in the getVariable command.

Have you had any success printing anything from OpenSHAPA? Maybe it would be good to try a quick and simple print to make sure that printing is working, because there are a lot of conditionals to troubleshoot in your script (and they depend on the actual data in the spreadsheet).

My suggestion would be to try this:

begin
foot = getVariable("foot")
for footcell in foot.cells
   puts footcell.onset.to_s + "\t" + footcell.reach
end
end

If that works, I would build in the other variables and test the conditionals as you go. Keep in mind that variables are case sensitive, and when accessing arguments in a script, omit the punctuation (so trial# should just be trial).

permanent link

answered 10 Mar '12, 03:38

JohnFranchak's gravatar image

JohnFranchak ♦
3964410
accept rate: 17%

Thank you so much, John. That helped! One more question. I fixed defining how to get the variables, but now when I try to run the script, I receive a blank screen (no errors, but also no data). Is this a factor of running the script too many times in OpenSHAPA, or some other issue?

Jen

begin

def get_ordinal(var)

id = getVariable("ID") foot = getVariaible("FOOT") sidepref = getVariable("SIDEPREF") limb = getVariable("LIMB")

id.cells.each do |idcell| foot.cells.each do |footcell| sidepref.cells.each do |sideprefcell| limb.cells.each do |limbcell|

            # Set up our conditional statements for what we want to print
              if idcell.onset <= footcell.onset and idcell.offset >= footcell.offset
                    if footcell.onset == sideprefcell.onset
                        if sideprefcell.onset == limbcell.onset

                              #subj study sex age walkexp crawlexp coder relcoder 
                              #trial# loc frststep reach nets change handnets restart reachand footonset footoffset 
                              #limb sideoffset

                              # Print ID

                            print idcell.subj + "\t" +

idcell.study + "t" + idcell.sex + "t" + idcell.age + "t" + idcell.walkexp + "t" + idcell.crawlexp + "t" + idcell.coder + "t" + idcell.relcoder + "t"

                            # Print FOOT.  Note how all non-alphanumeric characters are stripped out.
                    print footcell.trial# + "\t" + footcell.1ststep + "\t" + footcell.reach + "\t"+ footcell.nets + "\t"+ footcell.change + "\t"

                            # Print SIDEPREF    
                    print sideprefcell.handnets + "\t"  + sideprefcell.restart + "\t" + sideprefcell.reachhand + "\t" + footcell.onset.to_s + "\t" + footcell.offset.to_s + "\t"  + sideprefcell.offset.to_s + "\t"

                              # Print LIMB
                    print limbcell.limb + "\n"

                 end

end end end end end end end end

permanent link

answered 10 Mar '12, 03:10

jen_ducz's gravatar image

jen_ducz
1334
accept rate: 0%

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:

×46
×12
×6

question asked: 08 Mar '12, 01:13

question was seen: 4,359 times

last updated: 10 Mar '12, 03:38

powered by OSQA