DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Zero values in the begining of a channel

Hi,

 

 i want to delete zero values present in the begining of a channel.

 

Can any one please help on this?

 

Thanks 

Sunil Padikar M

0 Kudos
Message 1 of 3
(4,914 Views)

Hi Sunil,

 

To remove the zero values at the begining of a channel.

 

The two commands below will mark the "Group2/Result" channel values that are equal to zero as "novalues"

 

Ch("Group2/Result") = Ch("Group1/Input")+CTNV(Ch("Group1/Input")=0)

 

' this command will delete all "novalues" values.

 

Call ChnNovHandle("Group2/Result",,"Delete","X",False,False)

 

Would also suggest that you look in help for ProcessNoValues.    the ChnNovHandle command can also replace/delete from other channels at the same time.

 

The "novalue" value for a channel is quite useful and important concept to understand for DIAdem.

 

Paul

 

 

 

 

0 Kudos
Message 2 of 3
(4,891 Views)

Just thought I'd chime in - Pesmith8's method will work, but will do so for the entire channel (it will remove zeroes that occur at any point in the channel, not just the start).  You can also use a combination of ChnCalculate and IIF to convert any character to any other character (beyond simply numbers and NOVALUES) for entire channels.

If you truly ONLY want to remove 0's on the front of the channel (but let other zeroes remain), I would recommend:

  1. Use the ChnFind command to find the first row where your channel is not 0
  2. Loop through the rows prior to that row
  3. Convert each 0 to NoValues
  4. Use ChnNovHandle to remove NOVALUES once loop is complete

'Find first non-zero row
intMyResult = ChnFind("Ch(""Group1/Channel"")<>0",1)
'Convert all starting "0" rows to novalues
For i = 1 to (intMyResult - 1)
  chd(i,"Group1/Channel") = NV
Next 'i
'Remove novalues
Call ChnNovHandle("Group1/Channel","","Delete","X",True,True)

Note that this will also remove all NOVALUES found anywhere within the channel, so if your channel contains random nulls (NOVALUES) that you want to keep, you will need to change them to an impossible value first (-999999) then change them back after (probably using a combination of ChnCalculate and IIF)

Dim intMyResult, i
'Convert existing NOVALUES to -999999
Call ChnCalculate("Ch(""Group1/Channel"")=IIf(isnull(Ch(""Group1/Channel"")),-999999,Ch(""Group1/Channel""))" )
'Find first non-zero row
intMyResult = ChnFind("Ch(""Group1/Channel"")<>0",1)
'Convert all starting "0" rows to novalues
For i = 1 to (intMyResult - 1)
  chd(i,"Group1/Channel") = NV
Next 'i
'Remove novalues
Call ChnNovHandle("Group1/Channel","","Delete","X",True,True)
'replace existing NOVALUES
Call ChnCalculate("Ch(""Group1/Channel"")=IIf(Ch(""Group1/Channel"")=-999999,NOVALUE,Ch(""Group1/Channel""))" )

 

One final note, don't forget to consult the DIAdem help on any of these functions (especially ChnNoVHandle, as it can remove rows from a whole block of channels to keep lengths constant, if you have multiple channels that need trimmed to size).

-Josh

0 Kudos
Message 3 of 3
(4,801 Views)