On 20.07.2017 11:11, Maciej Izak wrote: > 2017-07-20 11:03 GMT+02:00 Bo Berglund <bo.bergl...@gmail.com > <mailto: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.
For completeness sake: https://www.freepascal.org/docs-html/current/ref/refse10.html#x22-210002.2 , especially the remark at the end. Regards, Sven _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal