Re: scope of variables

new topic     » goto parent     » topic index » view thread      » older message » newer message
Jeremy said...

It would nice to see some good examples. Maybe it would bring about a different proposal.

here an example, an editor as a text buffer with cursor position referenced by 2 top level variables bcol and bline and there is a procedure that modify the content of that buffer but must leave cursor position unchanged at exit. all the code elsewhere use bcol and bline to access character in buffer. It make sense to use local variables of same name inside that procedure

sequence buffer -- text buffer 
sequence bcol -- cursor column 
sequence bline -- cursro line 
 
--insert text at current cursor position and leave cursor where it is. 
procedure insert_text(sequence text) 
integer bcol=bcol -- local copy 
integer bline=bline -- local copy 
--- code here 
    
end procedure 
-- at exit bcol and bline are preserved without need to restore from a temporary storage 

Jacques

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu