ni.com is currently experiencing issues.

Support teams are actively working on the resolution.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with raising an error in a dataplugin.

Solved!
Go to solution

Hello,

I'll start with explaining what I want to do. I have to deal with a large number of file formats, that are all very different, and have their own dataplugin. I want to remove the step of having to use "Open with..." and then selecting the appropriate dataplugin, when the different files have to be loaded. To do this, I am modifying the code in each dataplugin to check that the file being loaded meets a certain condition unique to the appropriate file, or else an error is raised  and DIAdem moves onto the next dataplugin.

I am having issues simply checking the first available string in the file. Currently, I have:

1.      If File.GetNextStringValue(eString) <> "time" Then Call RaiseError("This dataplugin does not work with this file.")
2.      saChanNames = Split(File.GetNextLine,File.Formatter.Delimiters)
3.      saChanDataType = Split(File.GetNextLine,File.Formatter.Delimiters) 
4.      Set Block = File.GetStringBlock()

The problem with this is that because I'm using "GetNextStringValue", and the check works, when I get to line 2 the string "time" is not added to the array. Is there any way to check for "time" without progressing my position in the file, or is there a way to move back to the beginning after I use "GetNextStringValue"?

 

Thanks.

0 Kudos
Message 1 of 4
(3,026 Views)
Solution
Accepted by Kevin_McG
dim currPos : currPos = File.Position
If File.GetNextStringValue(eString) <> "time" Then Call RaiseError()
File.Position = currPos

You can use the Position property of the file to set it back to origin location.

Please make sure that you call RaiseError without parameters to signal that it is not your file.

0 Kudos
Message 2 of 4
(2,995 Views)
Solution
Accepted by Kevin_McG

In addition to AndreasK answer, please use the RaiseError command without any parameter:

If File.GetNextStringValue(eString) <> "time" Then Call RaiseError

This will express exactly what you described, the DataPlugin will return that it does not address the content of this file instead of an error.

Also, when indexed by DataFinder, there will be no error status, but the index status will be "eIndexedNotMyFile".

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

That's exactly the kind of idea I needed. Thanks.

0 Kudos
Message 4 of 4
(2,971 Views)