LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Script

Hi ALL

I need to use text script to edit my test program and send it to LabVIEW to execute,but i do not konw how.Below is my thinkings,

---------------------------------------------Script Start-----------------------------------------------------

a=2
if a>0
    fx1(para1,para2)                  //fx1:a LabVIEW VI with two parameters
else
    fx2(para1,para2,para3)       //fx2:a LabVIEW VI with three parameters
end
---------------------------------------------Script End-----------------------------------------------------
 
//My goal is to use scripts to write test programs and then hand them over to Labview for execution, such as a simple if condition where the two cases inside each call different Labview sub vi
 
my question is how to achieve my goal.
until now i have some conclusion
1. i need a EDITOR to edit my test programs,and the EDITOR can highlight my defined functions such as 'fx1'
2. the EDITOR can compile or somehow transfer the test programs to LabVIEW to execute
 
any suggestions welcomed
0 Kudos
Message 1 of 10
(1,009 Views)

Before you can write a script to help you create LabVIEW code, you need to know how to write LabVIEW code!  That is, you should probably spend a year or two writing LabVIEW programs (and really understand LabVIEW as a programming language) before you can use LabVIEW scripting to write LabVIEW programs.

 

How confident are you that you can write LabVIEW code to handle the very simple program you showed?  If you can't write the LabVIEW code, how do you expect to write a program to write the LabVIEW code for you?  What are you trying to accomplish?

 

Bob Schor

0 Kudos
Message 2 of 10
(999 Views)

Hi Bob

How confident are you that you can write LabVIEW code to handle the very simple program you showed?

I can write LabVIEW code to handle my simple demo.

 What are you trying to accomplish?

Editing and executing test sequences using text formatted scripts.

 

0 Kudos
Message 3 of 10
(985 Views)

Seems like a terrible idea.  Why on Earth would you want to do that?

Essentially you're wanting to write an app that translates your script pseudo code into LabVIEW code.

Unless your scripts are guaranteed to be primitive, writing the translator will be a very large undertaking.

0 Kudos
Message 4 of 10
(940 Views)

Hi Paul,

 


@paul_a_cardinale wrote:

Seems like a terrible idea.  Why on Earth would you want to do that?


I did that once (20 years ago) too: my goal was to make a testbench "sequencer" more configurable. The old version handle a fixed sequence of steps and I wanted a user-definable sequence of steps.

 

I made a simple translator to convert the old-style config files into a batch file producing the same sequence as before, but now I ("the user") was able to define my own test sequences with much more degree of freedom. In the end I implemented a simple interpreter with conditions and (nested) loops…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 10
(915 Views)

OK, so basically, you want a LV program to read in a file and execute the commands within it one by one, passing parameters to pre-defined functions within the code?

 

This sounds pretty much like a queued message handler, but with the inputs coming from file. This can be quite useful

 

Note that some replies here are assuming your use of the word "script" means you want to use "LabVIEW scripting" which allows you to use LabVIEW to actually program LabVIEW, something I would strongly advise against for this kind of purpose. Bear that in mind when mentioning "script" in a LabVIEW context. It might be better to refer to your "script" as an ASCII file instead.

0 Kudos
Message 6 of 10
(890 Views)

 

Spoiler
OK, so basically, you want a LV program to read in a file and execute the commands within it one by one, passing parameters to pre-defined functions within the code?

yes,user use the EDITOR to edit a text seq,generated the seq file,such as 'seq.m'.

 

0 Kudos
Message 7 of 10
(877 Views)

You keep referring to "the EDITOR".....

 

Which editor do you mean, do you have a specific editor in mind or do you mean just any old text editor?

0 Kudos
Message 8 of 10
(862 Views)

@Yuanxj wrote:

 

Spoiler
OK, so basically, you want a LV program to read in a file and execute the commands within it one by one, passing parameters to pre-defined functions within the code?

yes,user use the EDITOR to edit a text seq,generated the seq file,such as 'seq.m'.

 


OK.  I've done a couple of versions of that.  In the simple version, the test sequence was a .ini file.  The sections served only to clarify the structure of the test sequence (presented as a tree control); except that the test executive would jump to the last section (which had to be [Cleanup]) on abort.

Each line specified the (relative) path to a VI and parameters; like this: folder_path\my_test.VI; channel = A1, voltage = 2, insanity_level = 1000

The VIs all had to have the same connector pane, receiving 2 string arrays, one having the parameter names, the other having parameter values.

Note: To prevent your test executive from aborting if a test module aborts, use the "Call By Reference" to call the test modules.

Message 9 of 10
(821 Views)

you will need to implementa  command interpretor in labview, 

for each line, each code will make labview execute  previously implemented code. 

0 Kudos
Message 10 of 10
(801 Views)