OnNextInstrument()

View as Markdown

Definition

The OnNextInstrument() method is called at the beginning of the import process for each file that is being imported. This method is only called after it has determined the file contains a valid instrument.

Method Return Value

This method does not return a value.

Syntax

See example below. The NinjaScript code wizard automatically generates the method syntax for you.

Examples

1private int currentInstrumentIdx = -1;
2
3public string[] FileNames
4{ get; set; }
5
6protected override void OnNextInstrument()
7{
8 if (FileNames == null)
9 return;
10
11 // Try to read from file into the FileNames array created above
12 // Log an error and continue if the data is unreadable
13 try
14 {
15 reader = new StreamReader(FileNames[currentInstrumentIdx]);
16 }
17 catch (Exception exp)
18 {
19 NinjaScript.Log(FileNames[currentInstrumentIdx], exp.Message, LogLevel.Error);
20 continue;
21 }
22}