LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the field names of a structure using fieldnames... Works on the command line but not when I call a script that contains the command!!!

At the moment, I'm toying around with MathScript RT 2012 and structures a bit. Today, I noticed some curious behavior: When I define a structure and want to retrieve the names of its fields using the command fieldnames (which btw is not officially documented in the module help), it works if I do it directly on the command line within the MathScript window. But if I call a script which does exactly the same, all I get is a cell array of the right size but with empty strings as return value of the fieldnames command. Anyone a clue, why it behaves like this?

(short example script is attached as .txt, because the forum does not allow m-Files)

 

Regards,

achim1989

0 Kudos
Message 1 of 6
(6,348 Views)

Hi achim1989,

 

I tried to do the same like you. But both (command window and script file) had the same behaviour.

 

Could you please describe more clearly what you are doing?

Or could you give me some more information about how to reproduce this?

 

Thank you.

 

Regards

0 Kudos
Message 2 of 6
(6,284 Views)

Hi Penny,

 

first a counterquestion: If you say "had the same behavior" do you also mean, that it behaved correctly?

 

Sorry, but if it behaved correctly for you in both cases (directly in MathScript window and indirectly by calling the script) then I can't give you much more information. I'm using MathScript RT 2012 with LabVIEW 2012. 

 

Thank you for trying to help.

 

Regards,

Jörn

0 Kudos
Message 3 of 6
(6,280 Views)

Hi Jörn,

 

I meant, that the result is the same. I use the command window and geht the same result as if I use the m-file.

 

I attached two screenshots of my result.

Am I doing something wrong? Is that what you meant?

 

Regards,

Nina

Download All
0 Kudos
Message 4 of 6
(6,278 Views)

Yeah, I see what you mean. 

To replicate my behavior don't run the script from within the editor but change to the directory of the script using "cd <directory path>" and call the script by typing its name into the MathScript window.

 

Regards,

Jörn

0 Kudos
Message 5 of 6
(6,273 Views)

Hi Jörn,

 

now I know what you mean.

I´ll check this. Maybe this is a bug.

 

You could use the mathscript node in LabVIEW as a workaround. This should work.

You can use a probe to see what the result is.

 

Sorry for that.

 

Have a great day!

 

Best regards,

 

Nina

 

0 Kudos
Message 6 of 6
(6,256 Views)