User Tools

Site Tools


program_declare_a_program_.htm
Navigation:  Language Reference > 2 - Program Source Code Format > Program Format >====== PROGRAM (declare a program) ====== Previous pageReturn to chapter overviewNext page
PROGRAM
MAP
Prototypes
. [MODULE( )
Prototypes
END ]
END
global data
CODE
Statements
[RETURN]
Procedures

NewCNet.jpg

In Clarion#, you can add a default access modifier to the PROGRAM statement:

PROGRAM[, PUBLIC|,INTERNAL]

All declarations without explicit access modifier will have the default access modifier. The default for PROGRAM is PUBLIC.

blk2blue.jpg

PROGRAM The first declaration in a Clarion program source module. Required.
MAP Global procedure declarations. Required.
MODULE Declare member source modules.
prototypes PROCEDURE declarations.
global data Declare Global data which may be referenced by all procedures.
CODE Terminate the data declaration section and begin the executable code section of the PROGRAM.
statements Executable program instructions.
RETURN Terminate program execution. Return to operating system control.
procedures Source code for the procedures in the PROGRAM module.

The PROGRAM statement is required to be the first declaration in a Clarion program source module. It may only be preceded by source code comments. The PROGRAM source file name is used as the object (.OBJ) and executable (.EXE) file name, when compiled. The PROGRAM statement may have a label, but the label is ignored by the compiler.

A PROGRAM with PROCEDUREs must have a MAP structure. The MAP declares the PROCEDURE prototypes. Any PROCEDURE contained in a separate source file must be declared in a MODULE structure within the MAP.

Data declared in the PROGRAM module, between the keywords PROGRAM and CODE, is Global data that may be accessed by any PROCEDURE in the PROGRAM. Its memory allocation is Static.

Example:

PROGRAM                !Sample program declaration

 INCLUDE('EQUATES.CLW') !Include standard equates

 MAP

CalcTemp    PROCEDURE    !Procedure Prototype

 END

CODE

CalcTemp                !Call procedure

CalcTemp   PROCEDURE

Fahrenheit  REAL(0)      !Global data declarations

Centigrade  REAL(0)

Window WINDOW('Temperature Conversion'),CENTER,SYSTEM

    STRING('Enter Fahrenheit Temperature: '),AT(34,50,101,10)

    ENTRY(@N-04),AT(138,49,60,12),USE(Fahrenheit)

    STRING('Centigrade Temperature:'),AT(34,71,80,10),LEFT

    ENTRY(@N-04),AT(138,70,60,12),USE(Centigrade),SKIP

    BUTTON('Another'),AT(34,92,32,16),USE(?Another)

    BUTTON('Exit'),AT(138,92,32,16),USE(?Exit)

      END

CODE                         !Begin executable code section

OPEN(Window)

ACCEPT

 CASE ACCEPTED()

 OF ?Fahrenheit

  Centigrade = (Fahrenheit - 32) / 1.8

  DISPLAY(?Centigrade)

 OF ?Another

  Fahrenheit = 0

  Centigrade = 0

   DISPLAY

  SELECT(?Fahrenheit)

 OF ?Exit

  BREAK

 END

END

CLOSE(Window)

RETURN

See Also:

MAP

MODULE

PROCEDURE

PUBLIC

INTERNAL

Data Declarations and Memory Allocation

program_declare_a_program_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1