10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Procedures<strong>Guide</strong>lines for Writing C ProceduresUse the following syntax when writing a C procedure:procname([parameters]){processing statements}Note: You cannot name your C procedure “main,” and the procedure must notbe static. You can call any C procedure from 4GL except the “main” function.Follow these guidelines for passing parameters to C procedures:• Pass an integer as four bytes by value (or by reference if byref isspecified).• Pass a smallint as four bytes by value (or by reference if byref isspecified).• Pass a float as a double-format float by value (or by reference, if byref isspecified).To ensure full portability, pass all floating point parameters to Cprocedures using the byref qualifier. For example, the following codefragment declares some variables and calls a C procedure, passing theprocedure a floating-point parameter:/* variable declarations */test_float = float;test_integer = integer;test_return = integer...test_return = callproc myCproc (test_integer,byref(test_float));The corresponding C procedure is declared as follows:LongmyCproc (ivalue, fvalue)long ivalue;double *fvalue;{processing statements}• Pass a string as a pointer to a null-terminated string as follows:– Pass fixed-length string types (c, char) with trailing blanks up to theirfull length.– Pass variable-length string types (text, varchar) without trailingblanks.82 <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!