DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Select and Use Data Points Script

Solved!
Go to solution

Yes, definitely use EventLostFocus - wrote that way too quickly this morning.  Thanks for catching that, Kyle!

Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 21 of 33
(3,389 Views)

 

Hey Guys thanks for the ideas. I was able to finsd the function inserted below that gets rid of any non numeric characters to ensure the data in the text box is numeric

 

I have used the EventLossFocus() as an event handler however I was wondering if there is a way I could use the EventCustomAction()  to capture hitting enter on the keyboard as an event trigger?

 

Any Ideas?

 

 

Function parseInt(s)   
    Dim regNum, n, a, i
    Set regNum = new RegExp
    regNum.Pattern = "[0-9]"
    n = ""
    for i = 1 to Len(s)
          a = Right(Left(s,i),1)
        if RegNum.Test(a) then
          n = n & a 
        end if
    next
    If Len(n) = 0 Then
      parseInt = 0
    Else
      parseInt = n
    End if
End Function

 

 

 

 

Tim
0 Kudos
Message 22 of 33
(3,375 Views)

Hi smoothdurban,

 

Attached you find an example for the EventCustomAction.

 

Greetings

Walter

0 Kudos
Message 23 of 33
(3,367 Views)

Hey Brad,

 

Thanks for the info.  The commands listed below allow the user to select the actual X Y values where I am am looking for some additional capabilities,

 

First is there a way to correlate what data row number this X value corresponds to?  What I am and trying to do I to call the Find() function from the particular data point offset.

 

For Example

 

Find("ValueA >= ValueB", ChannelVals + Offset) 

 

So I am asking the user to select where they want the script to begin searching for where ValueA is >+ ValueB from ChannelVals

 

 

Secondly

 

Is there a way to grab the X or Y values of the cursor when intersecting multiple curves?  Currently if I call View,Sheets(1).Cursor.X1 it gives my the X1 value of the curve I have selected where I would like to grab the X1 Values of all of the curves in the view screen.

 

 

Thanks Again!

Tim
0 Kudos
Message 24 of 33
(3,354 Views)

Hey Brad,

 

I was able to find a way to obtain the data point by simply using  P1 or P2 as opposed to X1 or Y1.

 

However I am still looking to graph the data points from multiple curves simultaneously.

 

Thanks

Tim
0 Kudos
Message 25 of 33
(3,352 Views)

Hi Tim,

 

The P1 and P2 properties are only reliable if your VIEW cursor is latched to a curve, so beware.  The X1 and X2 properties always work.  I don't understand what you mean about "plotting the points from multiple curves simultaneously".  If you're in VIEW and accessing the cursor, don't you already have all the data plotted?  Do you perhaps want to highlight selected data points?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 26 of 33
(3,344 Views)

Hey Brad,

 

Allow me to elaborate

 

When I use the command to select data points either X1 or P1 it grabs the data point which is essentially the intersection point of the cursor and the selected curve. 

 

If there are multiple curves and if I want to acquire the intersect point between the cursor and the another curve I have to select the other curve so the cursor then locks itself to the other curve.

 

What I am trying to do is to select all of the intersect points between the cursor and curves.

 

Thanks 

Tim
0 Kudos
Message 27 of 33
(3,340 Views)

Tim,

 

Could you have the script select the next curve after getting the intersection point from the first curve?

 

Cheers,

KyleP
Applications Engineer
National Instruments
0 Kudos
Message 28 of 33
(3,327 Views)
Solution
Accepted by topic author smoothdurban

That's the solution I came up with.

 

I find the intersection point & value on one curve and then use that intersection value, utilizing the "Find()" function, to find the next curves intersection point.

 

See the code below.

 

CursorX1ValueArray(i) = View.Sheets(1).Cursor.P1 CursorX2ValueArray(i) = View.Sheets(1).Cursor.X1 R1 = CursorX2ValueArray(i) ResponseX1ValueArray(i) = Find("Ch(L3) >= R1", ResponseX1ValueArray(i) + 1)

 

Tim
Message 29 of 33
(3,322 Views)

I am not sure if I should of created a new thread for this but I figured I would continue this one as it pertains to using the Find() function. 

 

I was able to call for user iteration using a SUDD1gShow() function within a do while loop as suggested.  In my do While loop the user is prompted multiple time to select the desired data points.  The series of prompts work fine and what I am basically doing is prompting the user for data points and then using the point coordinates to find the first instance of a Y value from that data point using the Find()

 

To add functionality I have given the user the chance to repeat the series of prompts if they are unhappy with the first set of selections.  The problem I am having is when the user opts to reselect the starting data points the find function does not find matching values (thus Find() = 0) when it should be able to find the exact same first instance points a previously selected.

 

I suspect the Find() function is starting at a point where it had left off from the previous series of function calls, therefore telling me it did not find a data point which meets my conditions.

 

I have attached a partial section of code below that illustrates the series of prompts in the for loop.  The problem when I am having is when the for loop is entered for the second time the Find() function doesn't find a satisfying condition which results is CtrlTimeVals(i) = 0.

do while SUDDlgShow("SelectStepDataPoints",MyFolders(0)&"Load File.SUD",NULL) <> "IDCancel" For i = 0 to NumberOfStepsSelected-1 Call InteractionOn("Click Here After "+ControlValueArray(i) +" Nm Load Point Has Been Selected") CtrlTimeVals(i)= Find("Ch(L2) >= R1", CtrlTimeVals(i)+ ControlPointValueArray(i)) Next Loop

 

 

Tim
0 Kudos
Message 30 of 33
(3,307 Views)