Elmo HARmonica, HARSFEN0602 software manual Global variables, Jumps

Models: HARmonica HARSFEN0602

1 220
Download 220 pages 51.63 Kb
Page 46
Image 46

HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

exits, the value the automatic variables is not saved.

 

Automatic variable cannot be a vector.

 

Example: In the example of the STATISTIC function, variable k is the automatic variable

44

5.6.5Global variables

A function can refer a persistent variable. In this case the referred persistent variable must be declared global inside function and must be defined above function definition. The global keyword is obligatory; otherwise the variable will be referred as an automatic variable of the function.

The dimension of a persistent variable is defined once a program during its definition and the same for this global variable in all functions where it is used. The legal way to declare the dimension of a persistent variable inside function is empty square brackets after its name or absence any brackets.

Example: In the example of the STATISTIC function, variable vec[11] is the global variable. It is defined above the function definition and inside the function body it is redeclared as global.

float temp;

Declare the global vector variable

int vec[10] ;

Declare the global vector variable

 

function [float a]=func(int b )

Declaration of a function func

float temp ;

Declare temp as an automatic variable,

 

because the global keyword is absent.

Function body

return

The end of the function

 

function [float a]=func1(float temp )

Declaration of a function func1. In this case

 

temp is not global variable, but an input

 

argument.

 

return

The end of the function

 

function [float a]=func2(float b )

Declaration of a function fun2.

global float temp ;

Redeclaration of the global variable temp. In

 

this function temp is the global variable.

global int vec[] ;

Redeclaration of the global variable vec.

 

Notice that its dimension is omitted during

 

redeclaration and its actual dimension is 10 as

 

it is defined above.

5.6.6Jumps

Syntax:

goto ##LABEL1

The jump (goto) command instructs the program to continue its execution at the label specified by the jump command.

Page 46
Image 46
Elmo HARmonica, HARSFEN0602 software manual Global variables, Jumps