Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 module problems
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nick




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: 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.
Nick




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: