# Library format

Functions within the library have the general structure:

```
{rc=}_CP_ xxx({arg0{,arg1{,...}}});
```
where `_CP_`*xxx* is a
general pattern for the name. It is always prefixed with `_CP_` to avoid naming conflicts with standard libraries and is suffixed
with an entirely lowercase tag such as `_CP_execute`. Macros are provided using the same model, but they use uppercase
such as such as `_CP_SLEN`.

*arg0* and *arg1* are arguments. The result code is `rc`. Almost all functions return an integer result. This
result is -1 if an error occurs, and the global variable `_CP_errno` is set to one of the following error codes:

| Error | Result |
| --- | --- |
| PE_ACCESS | Cannot access file. |
| PE_BAD_PARAMS | Too many parameters on a call. |
| PE_BADATTR | Bad attribute. |
| PE_BADF | File not opened. |
| PE_BADMD | Bad master dictionary or master dictionary password. |
| PE_BADUSER | Bad user-ID or user password. |
| PE_CALLMAIN | Tried to call a main as a subroutine. |
| PE_CONV | Conversion error. |
| PE_DEBUG | Debugger entered. |
| PE_END_LIST | No more items on select. |
| PE_EOF | End of file/item. |
| PE_GETSEND | Bad PIB on get/send. |
| PE_ILL_KEY | Bad key operator. |
| PE_INIT | Virtual machine not booted or attached. |
| PE_INVAL | Invalid call. |
| PE_LEVEL | Debugger entered. |
| PE_LOAD_ERR | Unable to load FlashBASIC subroutine. |
| PE_LOCK | Item is locked. |
| PE_LONG_STR | Too long a string for heading. |
| PE_MISCERR | Miscellaneous logon error. |
| PE_MISSING | File not found. |
| PE_NFILE | Not enough memory to open more files. |
| PE_NONUM | Not a number. |
| PE_NOSPACE | Could not allocate workspace. |
| PE_NOTROOT | Bad root variable. |
| PE_PROC | Proc read error. |
| PE_TAPE | Tape error. |
| PE_TMOUT | Input time out. |
| PE_TRUNC | String truncated due to lack of memory. |

---
Source: https://d3codex.com/cfunctions/library-format/ - part of the D3Codex reference.
