Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

How to sum values from multiple lines in a DataTable?

I have a Lookout program which uses a DataTable to allow users to write basic programs (relay on/off times, which relays change state, and pause times).  The DataTable cursor position changes to advance from one program stage to another.  

 

What I would like to do is sum up the times from all the various stages.  Can anyone suggest how I might iterate through the DataTable using Lookout alone?  

 

Thanks,

 

Dave 

0 Kudos
Message 1 of 6
(5,932 Views)

Do you want to sum up the Datatable cells, for example, from A1 to A100?

 

If you want to do it programmatically, the Accumulator, Pulse and Counter may help you. Use the Pulse to count from 1 to 100. Give the count to the datatable cusror, for example, A.1. Use Accumulator to sum A.1. The trigger of the Accumulator is also the Pulse.

 

I have not tried it, but I think it should work. But if you just have 10 rows to sum up, I think you can just say A1+A2+...+A10.

Ryan Shi
National Instruments
0 Kudos
Message 2 of 6
(5,910 Views)

Thanks Ryan, 

 

Are there any other "general practices" for performing state-machine like functions with Lookout?

 

I would like the software so much more if I had the ability to do something as simple as:

 

while (x==0)

if (y==2) then { dothis() }

}

 

0 Kudos
Message 3 of 6
(5,886 Views)

Can you give a detail example of "dothis()"?

 

The expression in Lookout is not like the C codes. We don't have loop in expression, but since the expression is event-driven, maybe we can use other ways to implement your codes or get similar functionality.

Ryan Shi
National Instruments
0 Kudos
Message 4 of 6
(5,866 Views)

I have tried to make 'loops' similar to that one but Lookout shows a message that iterations or loops for a variable are not allowed.

 

You can use a sequencer but there are 2 inconvenients:

1.- For a fast computer every step of the sequencer cannot be faster than 0.1 - 0.2 seconds. If you have many iteraciones, it will take some time.

2.- The sequencer object has a maximimum of 100 steps.


Ryan S. Here are questions for you:

 

1.- Is there a way to add in the lks file statements and or functions using existing variables? What can be done and what not?

2.- Is there a way to insert comments in the lks file?

 

Thanks in advance.

 

Rudy Lopez

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

I don't understand your question 1. What do you mean by "existing variable"? Actually Lookout doesn't have the "variable" like the one in C, what you can do is to store the data in objects, such as expression, pot, datatable, etc, and then get the value from objects.

 

You can add comments to the .lks file. Use

/* ... */

or

// .....

 

But the problem is that when you load the file, lookout will omit the comments, which means after you save the process, the comments cannot be saved back to the lks file.

Ryan Shi
National Instruments
Message 6 of 6
(5,701 Views)