Forums

Multiple Source Files?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Multiple Source Files?

Postby JimmyD » Tue Jan 10, 2012 4:36 pm

Hey,
I was just wondering how to use multiple source files in Cobra? It's used in large programs, but for simplicity sake let's say I have two files:

class File1

def main
f2 = File2()
f2.sayHello
Console.WriteLine(f2.add(5, 5))


class File2

def sayHello
print "Hello from file2!"

def add(x as int, y as int)
return x + y


How would I use 'File2' in 'File1'?

Thanks in advance,

- JimmyD
If you live among wolves, you have to act like a wolf.
JimmyD
 
Posts: 7
Location: IA

Re: Multiple Source Files?

Postby Charles » Tue Jan 10, 2012 4:58 pm

cobra File1.cobra File2.cobra

# or to just compile:
cobra -c File1.cobra File2.cobra

You can also dictate the name of the executable and pass other options. See the CommandLine wiki page.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Multiple Source Files?

Postby JimmyD » Tue Jan 10, 2012 8:54 pm

Awesome,
Thank you very much Mr. Charles. :)

- JimmyD
If you live among wolves, you have to act like a wolf.
JimmyD
 
Posts: 7
Location: IA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 18 guests