From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

cancel
Showing results for
Did you mean:

Solved!
Go to solution

Import txt file into report

I have an Arinc signal that I have decoded into each of its digital I/Os.  Since I have over 150 I/Os I needed a way to sort and do a quick report on them.

I have three categories.

1. Stayed =1 throughout test

2. Stayed = 0 throughout test

3. Changed either from 0 --> 1 or 1-->0 during the test.

I want to just put a list of the signals for each of these categories into my report.

I have created a txt file for these to go in, but how do I import that into my report?

Or is there an easier way?

Here is an example of my code...

```'HCM1
'HCM1 Label 104 decode - Untitled 3
Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HSOV_A1_CLOSED"")= GetB (Ch(""[1]/Untitled 3""),0)")
Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HSOV_A2_CLOSED"")= GetB (Ch(""[1]/Untitled 3""),1)")
Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HPP_A_RUNNING"")= GetB (Ch(""[1]/Untitled 3""),2)")
Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_SYS_A_HI_TEMP"")= GetB (Ch(""[1]/Untitled 3""),4)")
Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_SYS_A_LO_PRS"")= GetB (Ch(""[1]/Untitled 3""),7)")
Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HPP_A_LO_PRS"")= GetB (Ch(""[1]/Untitled 3""),12)")
Call Calculate ("Ch(""HCM1_104/HCM_1_CAS_HPP_A_HI_TEMP"")= GetB (Ch(""[1]/Untitled 3""),13)")

'HCM1 Label 105 decode - Untitled 4
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HSOV_A1_FAIL"")= GetB (Ch(""[1]/Untitled 4""),0)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HSOV_A2_FAIL"")= GetB (Ch(""[1]/Untitled 4""),1)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_EDP_A1_FAIL"")= GetB (Ch(""[1]/Untitled 4""),2)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_EDP_A2_FAIL"")= GetB (Ch(""[1]/Untitled 4""),3)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_SYS_A_PRS_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),6)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_SYS_A_RET_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),7)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_EDP_A1_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),8)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_EDP_A2_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),9)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HPP_A_LO_QTY"")= GetB (Ch(""[1]/Untitled 4""),11)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HPP_A_FAIL"")= GetB (Ch(""[1]/Untitled 4""),12)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_HPP_A_CDF_FLT_CLG"")= GetB (Ch(""[1]/Untitled 4""),14)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_IV_A_FAIL"")= GetB (Ch(""[1]/Untitled 4""),15)")
Call Calculate ("Ch(""HCM1_105/HCM_1_FLT_IV_A_FAIL_LOCAL"")= GetB (Ch(""[1]/Untitled 4""),16)")

'HCM1 Label 106 decode - Untitled 5
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_PF_DPI_FAIL"")= GetB (Ch(""[1]/Untitled 5""),0)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_RF_DPI_FAIL"")= GetB (Ch(""[1]/Untitled 5""),1)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_EDP_A1_CDF_DPI_FAIL"")= GetB (Ch(""[1]/Untitled 5""),2)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_EDP_A2_CDF_DPI_FAIL"")= GetB (Ch(""[1]/Untitled 5""),3)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_EDP_A1_PS_FAIL"")= GetB (Ch(""[1]/Untitled 5""),4)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_EDP_A2_PS_FAIL"")= GetB (Ch(""[1]/Untitled 5""),5)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_PX_FAIL"")= GetB (Ch(""[1]/Untitled 5""),6)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_TX_FAIL"")= GetB (Ch(""[1]/Untitled 5""),7)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_SYS_A_QX_FAIL"")= GetB (Ch(""[1]/Untitled 5""),8)")
Call Calculate ("Ch(""HCM1_106/HCM_1_HSOV_A1_IND_FAIL"")= GetB (Ch(""[1]/Untitled 5""),10)")
Call Calculate ("Ch(""HCM1_106/HCM_1_HSOV_A2_IND_FAIL"")= GetB (Ch(""[1]/Untitled 5""),11)")
Call Calculate ("Ch(""HCM1_106/HCM_1_EDP_A1_FAIL"")= GetB (Ch(""[1]/Untitled 5""),12)")
Call Calculate ("Ch(""HCM1_106/HCM_1_EDP_A2_FAIL"")= GetB (Ch(""[1]/Untitled 5""),13)")
Call Calculate ("Ch(""HCM1_106/HCM_1_FLT_FV_A_FAIL"")= GetB (Ch(""[1]/Untitled 5""),14)")
Call Calculate ("Ch(""HCM1_106/HCM_1_HSOV_A1_RELAY_FAIL"")= GetB (Ch(""[1]/Untitled 5""),15)")
Call Calculate ("Ch(""HCM1_106/HCM_1_HSOV_A2_RELAY_FAIL"")= GetB (Ch(""[1]/Untitled 5""),16)")

Dim k, m, pMyChn, result, ArincTrue, intMyHandle01, intMyHandle02,intMyHandle03,intMyText, intMyError01, intMyError02, intMyError03
intMyHandle01 = TextFileOpen("C:\ArincTrue.txt",tfCreate or tfWrite)
intMyHandle02 = TextFileOpen("C:\ArincFalse.txt",tfCreate or tfWrite)
intMyHandle03 = TextFileOpen("C:\ArincChange.txt",tfCreate or tfWrite)
For k = 2 to 4
For m = 1 to GroupChnCount(k)
Set pMyChn = Data.Root.ChannelGroups(k).Channels(m)
Result = ChnValMax(pMyChn)-ChnValMin(pMyChn)

If Result = 0 and ChnValMax(pMyChn) > 0 then
intMyText= TextfileWriteLn(intMyHandle01, pMyChn.Name)
elseif result= 0 and ChnValMax(PMyChn) = 0 then
intMyText= TextfileWriteLn(intMyHandle02, pMyChn.Name)
else
intMyText= TextfileWriteLn(intMyHandle03, pMyChn.Name)
End If

Next
Next
intMyError01 = TextFileClose(intMyHandle01)
intMyError02 = TextFileClose(intMyHandle02)
intMyError03 = TextFileClose(intMyHandle03)```

Message 1 of 3
(5,367 Views)
Solution
Accepted by topic author 2Pale4TX

Re: Import txt file into report

Hi 2Pale4TX,

You can't easily reference the content of an ASCII file.  Instead, I suggest you make a new Group of 3 text channels that you can drag onto a REPORT table.

```Dim k, m, z, ResultsGroup, TrueChannel, FalseChannel, ChangeChannel, Group, Channel, Result
For k = 2 to 4
Set Group = Data.Root.ChannelGroups(k)
For m = 1 to Group.Channels.Count
Set Channel = Group.Channels(m)
ChMax = CMax(Channel)
ChMin = CMin(Channel)
Result = ChMax - ChMin
If Result = 0 and ChMax > 0 Then
z = TrueChannel.Size + 1
TrueChannel(z) = Channel.Name
Elseif Result = 0 and ChMax = 0 Then
z = FalseChannel.Size + 1
FalseChannel(z) = Channel.Name
Else
z = ChangeChannel.Size + 1
ChangeChannel(z) = Channel.Name
End If
Next ' m
Next ' k```

National Instruments

Message 2 of 3
(5,337 Views)