Computer Science Canada

module problems

Author:  Nick [ Sat Aug 25, 2007 7:57 am ]
Post subject:  module problems

i can create modules fine as i have done in the past but i was wondering if a varible declared in one procedure and be sent to another procedure without redeclaring it

ex:

Turing:
unit

module something

procedure someProc
var someVar:int
end someProc

procedure anotherProc
put someVar
end anotherProc
end something


would this be possible... I know the way presented is not but perhaps there is another way

Author:  Clayton [ Sat Aug 25, 2007 9:04 am ]
Post subject:  RE:module problems

Just use an (for lack of a better word) instance variable for your module. This instance variable's scope is only within your module, so it would look something like this:

code:

module Foo

    var bar : int

    procedure baz (qux : int)
        bar := qux
    end baz

    function fuzz : int
        result bar
    end fuzz
end Foo


NOTE: Also, take a good look at coding conventions in Turing. Check the Turing Waklthrough for wtd's Turing Syle Guidelines.

Author:  Nick [ Sat Aug 25, 2007 9:08 am ]
Post subject:  RE:module problems

oh thanks a lot why didn't i think of that seems so obvious now


: