-
Notifications
You must be signed in to change notification settings - Fork 14
Running and debugging
To run PicoC scripts one should begin by transferring plain-text C source files, with .c extension, to the calculator. If you prefer a more tedious alternative, you can also write a C program using the editor in Utilities and then saving the file with extension .c.
These files can be executed by opening the Utilities file manager, then opening the details screen for the C source file, and pressing F4 or EXE, ou simply by pressing EXE twice from the file listing. If pressing EXE opens the file as text instead, this means you have the wrong edition of Utilities - the one without PicoC support.
PicoC in Utilities does not offer any kind of debugging facilities. Like with native add-in development, your best bet is to stick to drawing stuff on the screen to indicate your program status as it runs.
However, PicoC does syntax checking, and if it runs into a run-time error, like undefined symbols, it will stop and complain about it, indicating the error and the line number where the error occurred.
Full terminal emulation isn't supported, which means you won't be able to use the standard library functions for getting input and returning output - just like what happens with Prizm add-ins. However, for convenience, any output will be displayed after the script finishes running, or once an error occurs.
For example, if one tries to use a undefined symbol, the following is shown:
If a script writes to the terminal (for example, using printf), when the program finishes running the following will be shown:
The "code" is the exit code of the program, which is 0 by default, and corresponds to the parameter of the exit
function. So to exit with code 1234, one could do exit(1234);
.
This screen with the exit code and output is only shown if the script produces any terminal output, or if the exit code is not zero.