# ScriptStartFBlock Method - neoVI API

This method starts the specified function block within a script on a neoVI device.

{% tabs %}
{% tab title="C/C++ Declare" %}

```cpp
int _stdcall icsneoScriptStartFBlock(void * hObject, unsigned int iFunctionBlockIndex);
```

{% endtab %}

{% tab title="Visual Basic .NET Declare" %}

```vbnet
Public Declare Function icsneoScriptStartFBlock Lib “icsneo40.dll” (ByVal hObject As IntPtr, ByVal fb_index As UInt32) As Int32
```

{% endtab %}

{% tab title="C# Declare" %}

```csharp
[DllImport(“icsneo40.dll”)] public static extern Int32 icsneoScriptStartFBlock(IntPtr hObject,UInt32 fb_index);
```

{% endtab %}
{% endtabs %}

**Parameters**

hObject

\[in] Specifies the driver object created by [OpenNeoDevice](https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/basic-functions-overview-intrepidcs-api/openneodevice-method-intrepidcs-api).

iFunctionBlockIndex

\[in] The index value of the function block to start

**Return Values**

1 if the function succeeded. 0 if it failed for any reason. [GetLastAPIError](https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/error-functions-overview-intrepidcs-api/getlastapierror-method-intrepidcs-api) must be called to obtain the specific error. The errors that can be generated by this function are:

NEOVI\_ERROR\_DLL\_NEOVI\_NO\_RESPONSE = 75

NEOVI\_ERROR\_DLL\_SCRIPT\_INVALID\_FUNCBLOCK\_INDEX = 219

NEOVI\_ERROR\_DLL\_SCRIPT\_NO\_SCRIPT\_RUNNING = 226

**Remarks**

The script containing the specified function block must have been successfully downloaded to the neoVI using [LoadScript](https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/deprecated-functions-overview-intrepidcs-api/coremini-script-interface-overview-intrepidcs-api/scriptload-method-intrepidcs-api). The valid index values for a function blocks within a script can be found in the cmvspy.vs3cmb.h file that is produced by Vehicle Spy. Please see Vehicle Spy documentation.

### Examples

{% tabs %}
{% tab title="C/C++ Example:" %}

```cpp
int iRetVal;
unsigned long lLastErrNum;

iRetVal = icsneoScriptStartFBlock(hObject, Function_Block_1);
if(iRetVal == 0)
{
    printf("\nFailed to start the function block);
}
else
{
    printf("\nSuccessfully started the function block");
}
```

{% endtab %}

{% tab title="C# Example:" %}

```csharp
Int32 iResult;

//Start Function Block in CoreMini
iResult = icsNeoDll.icsneoScriptStartFBlock(m_hObject, Convert.ToUInt32(cboFBToChange.SelectedIndex));

if (iResult == 0)
{
    lblFBStatus.Text = "Function Block failed to Start";
}
else
{
    lblFBStatus.Text = "Function Block Started";
}
```

{% endtab %}

{% tab title="Visual Basic .NET Example:" %}

```vbnet
Dim iResult As Int32

'//Start Function Block in CoreMini
iResult = icsneoScriptStartFBlock(m_hObject, Convert.ToUInt32(cboFBToChange.SelectedIndex))

If iResult = 0 Then
    lblFBStatus.Text = "Function Block failed to Start"
Else
    lblFBStatus.Text = "Function Block Started"
End If
```

{% endtab %}
{% endtabs %}
