Cicode Programming Reference > Writing Functions > Following Cicode Syntax

Following Cicode Syntax

Some programming languages have strict rules about how the code needs to be formatted, including the indenting and positioning of the code structure. Cicode has no indenting or positioning requirements, allowing you to design your own format - provided only that you follow the correct syntax order for each statement. However, it is a good idea to be consistent with your programming structure and layout, so that it can be easily read and understood.

For details about programming standards, see the section titled Using Cicode Programming Standards, which includes sections on:

For information on problem solving, see the sections onModular Programming, Defensive Programming, Function Error handling, or Debugging Cicode.

The following is an example of a simple Cicode function:

/*	
This function is called from a keyboard command. The operator presses the key and enters the name of the page to be displayed. If the page cannot be displayed, an error message is displayed at the prompt AN.
*/
INT
FUNCTION
MyPageDisplay ( STRING sPage ) ! pass in the name of the page to be displayed
! declare a local integer to hold the results of the pagedisplay function
INT Status;
! call the page Cicode pagedisplay function and store the result
Status = PageDisplay ( sPage ) ;
! determine if the page display was successful
IF Status < > 0 THEN ! error was detected
! display an error message at the prompt AN
DspError ( "Cannot Display " + sPage ) ;
END
! return the status to the caller
RETURN Status;
END

The rules for formatting statements in Cicode functions are simple, and help the compiler in interpreting your code.

It is good practice to use white space to make your code more readable. In the example above, the code between the FUNCTION and END statements is indented, and the statement within the IF THEN conditional executor is further indented to make the conditions and actions clear. Develop a pattern of indentation - and stick to it. Extra blank lines in the code make it easier to read (and understand).