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

Username:   Password: 
 RegisterRegister   
 pass arrays to modules?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Clayton




PostPosted: Mon Apr 10, 2006 6:14 pm   Post subject: pass arrays to modules?

hey, just wondering, is it possible to pass entire arrays to a module and have that module return the array (ex. in a sorting module). if its possible could u plz let me know how thnx
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Mon Apr 10, 2006 6:18 pm   Post subject: (No subject)

Hmm? Unless I mistake your question, of course.

Modules are able to include procedures and functions which are in turn able to accept arrays as arguments.
Clayton




PostPosted: Mon Apr 10, 2006 6:20 pm   Post subject: (No subject)

but how would you pass the array from a main program to a module without splitting an array up into different pieces (ex. 1 piece of info at a time)
[Gandalf]




PostPosted: Mon Apr 10, 2006 6:26 pm   Post subject: (No subject)

The same way you would pass an array to a procedure or function:
code:
var myGlobalArray : array 1 .. 3 of int := init (3, 4, 6)
proc putArray (localArray : array 1 .. * of int)
    for i : 1 .. upper (localArray)
        put localArray(i)
    end for
end putArray
putArray(myGlobalArray)

It works the same for a procedure in a module.
Clayton




PostPosted: Mon Apr 10, 2006 6:44 pm   Post subject: (No subject)

oh ok thnx alot, talk about a brain fart lol
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  [ 5 Posts ]
Jump to:   


Style:  
Search: