Please enable JavaScript to view this site.

Added May 2019

The functional directive .EXTERN(expr), when used within a function or procedure, changes the normal scope search rules (first local, then module, then global) for all of the variables within the enclosed expression, to consider only global variables. For example:

map1 state$,S,20,"Ignorance"

...

Function Fn'Foo() as i4

    map1 state$,S,.sizeof(.extern(state$))  ! S,20

    state$ = "Bliss"                        ! assign local state$

    print .extern(state$);" is ";state$     ! Ignorance is Bliss

EndFunction

 

In the above function, there are references to two variables named state$: one local to the function and one global. Normally, the scope rules would give the local variable precedence, even if ++pragma auto_extern or an explicit ++extern state$ directive was specified. The use of the .extern() functional directive allows the function to selectively and explicitly refer to the global version of the variable.

Example

The following illustrates and emphasizes that the .EXTERN(expr) might encompass multiple variables, all of which will refer to the global instance.

map1 seccao,b,1

map1 array$(2),s,0

 

array$(1) = "element 1"

array$(2) = "element 2"

seccao = 2

call FN'teste(1)

end

 

function FN'teste(seccao as b1) as b1

++extern array$()

        ? array$(seccao)            ! array$() is global but seccao is local ("element 1")

        ? .extern(array$(seccao))   ! both array$ and seccao global ("element 2")

endfunction

 

History

2019 May, A-Shell 6.5.1551:  Feature added to A-Shell

Created with Help+Manual 9 and styled with Premium Pack Version 5 © by EC Software