Files
harbour-core/tests/statics.prg
vszakats a4a357a18b 2013-03-15 11:12 UTC+0100 Viktor Szakats (harbour syenar.net)
* /harbour/* -> /*
    * moved whole Harbour source tree one level up to
      avoid single 'harbour' top dir
2013-03-15 11:13:30 +01:00

73 lines
895 B
Plaintext

/*
* $Id$
*/
// Testing Harbour statics variables management
#ifndef __HARBOUR__
#include "clipper.ch"
#endif
STATIC s_z := "First"
PROCEDURE Main()
LOCAL i, cb
STATIC a := "Hello", b := { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
? a
? b[ 2 ]
Two()
? "Ok!"
FOR i := 1 TO 10
NumStat()
NEXT
cb := DetachVar( 10 )
FOR i := 1 TO 10
? Eval( cb, b[ i ] )
NEXT
RETURN
FUNCTION Two()
STATIC a := "Test"
? a
RETURN NIL
FUNCTION THREE( p )
? p
RETURN p
PROCEDURE NumStat( a )
STATIC s_n := 1
LOCAL cb
// STATIC m := s_n // uncomment it to see an error
// STATIC m := Time() // uncomment it to see an error
HB_SYMBOL_UNUSED( a )
cb := {| x | s_z + Str( x ) }
? ++s_n
? Eval( cb, s_n )
RETURN
FUNCTION DetachVar( xLocal )
STATIC xStatic := 100
RETURN {| x | ++xStatic, x + xStatic + xLocal }