19.0.0 released Nov 08, 2023
Non request

Non-request source files implement common code used in request-handling .vely files, meaning they are used to implement functionality that is used in more than one place in a program. Their names always start with an underscore ('_').

So for instance, file '_display.vely' would never handle any requests directly - such file may be (for example) implementing common functions that display various HTML statements; those function's prototypes should be declared in both request-handling and non-request files, typically in a header file included (see Examples).

When Vely code is compiled, both request and non-request source code is automatically picked up - all files with .vely extensions are used.

A non-request source file can implement any number of functions which can be named in any fashion. However, Vely will declare a prototype for a function with the same name, saving you to the effort to do that, should you decide to implement it. For example, if you have function "void _display_table()" in file "_display.table.vely":
#include "vely.h"

void _display_table() {

then the prototype for function "void _display_table()" will be automatically generated and you do not have to do it manually.
In the following example, a list of customer names is shown (note functions "header()" and "footer()" that display a header and a footer), and the code is implemented in request source file "show.vely". Note that header file ("common.h") with prototypes for "header()" and "footer()" is included in "show.vely":
#include "vely.h"
#include "common.h"

void show() {
    run-query @db="select name from cust" output name
        query-result  name

Function _display() is  implemented in non-request source file "_display.vely". Note that header file ("common.h") with prototypes for "header()" and "footer()" is included here too:
#include "vely.h"
#include "common.h"

void header () {
void footer() {

Finally, in order for functions "header()" and "footer()" to be properly declared, you'd add header the above header file "common.h" (you can name it anything, but don't forget to change it elsewhere):
#include "vely.h"

void header ();
void footer();

Both files ("show.vely" and "_display.vely") will be automatically picked up, compiled and linked.
See also
See all

You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a dofollow link back to this page - see full license at CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind. Icons from table-icons.io copyright PaweĊ‚ Kuna, licensed under MIT license.