> For the complete documentation index, see [llms.txt](https://docs.intrepidcs.com/vspy-3-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.intrepidcs.com/vspy-3-documentation/3.9.16/vehicle-spy-main-menus/main-menu-scripting-and-automation/c-code-interface/c-code-interface-functions-and-events/functions-and-events-function-blocks.md).

# Functions and Events: Function Blocks

The C Code Interface provides functions for interacting with Vehicle Spy [Function Blocks](/vspy-3-documentation/3.9.16/vehicle-spy-main-menus/main-menu-scripting-and-automation/function-blocks.md).  Function blocks can capture message data to a file, replay messages or execute a script. Therefore your C code has high level control over this powerful part of Vehicle Spy. You can start, stop, trigger or save data related to function blocks directly from C.\
\
All function block related functions begin with the prefix "FB\_". The function then contains the function block name and finishes with the API name. For example, if a function block was named "Test", the function to start it would be "FB\_Test\_Start()". See the table and picture below for more details.

**Table 1: Function Block APIs Available**

| API            | Description                                                     |
| -------------- | --------------------------------------------------------------- |
| IsRunning()    | Returns 1 if the function block is running.                     |
| IsTriggered()  | Returns 1 if the function block is triggered.                   |
| NumCollected() | Returns the number of messages collected by the function block. |
| Save()         | Saves the function block data.                                  |
| Start()        | Starts the function block.                                      |
| Stop()         | Stops the function block.                                       |
| Trigger()      | Triggers the function block.                                    |

![Figure 1: The C code project has full control of Vehicle Spy's function blocks - just type "FB\_".](https://content.gitbook.com/content/l4AHCa3zNeJQNFBrgCqy/blobs/LFeCA7ZW26rZwyzy1rrg/fblock_control.gif)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.intrepidcs.com/vspy-3-documentation/3.9.16/vehicle-spy-main-menus/main-menu-scripting-and-automation/c-code-interface/c-code-interface-functions-and-events/functions-and-events-function-blocks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
