Page 1 of 1

Multiple Source Files?

PostPosted: Tue Jan 10, 2012 4:36 pm
by JimmyD
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

Re: Multiple Source Files?

PostPosted: Tue Jan 10, 2012 4:58 pm
by Charles
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.

Re: Multiple Source Files?

PostPosted: Tue Jan 10, 2012 8:54 pm
by JimmyD
Awesome,
Thank you very much Mr. Charles. :)

- JimmyD