2017-07-20 11:03 GMT+02:00 Bo Berglund <bo.bergl...@gmail.com>: > So since I don't really want to use a global, is it possible to > declare a local variable static in the sense that it retains its > values across calls to the procedure? > If so how is it done? >
procedure foo; {$PUSH} const{$J+} s : string =''; {$POP} begin writeln(s); if s = '' then s := 'hello from static local variable'; end; begin foo; // will print empty line foo; // will print 'hello from static local variable' foo; // will print 'hello from static local variable' end. -- Best regards, Maciej Izak
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal