PDA

View Full Version : How to use Oxygene for Java Command Line?



paul_nicholls
12-04-2012, 03:20 AM
Hi all,
I am having trouble using the Oxygene for Java Command Line to compile a very simple Java project:

unit Mandelbrot;

interface

type
ConsoleApp = class
public
class method Main(args: array of string);
end;

implementation

class method ConsoleApp.Main(args: array of string);
const
cols = 78;
lines = 30;
chars = " .,:;=|iI+hHOE#$-";
maxIter = Length(chars);
begin
var minRe := -2.0;
var maxRe := 1.0;
var minIm := -1.0;
var maxIm := 1.0;
var im := minIm;
while im <= maxIm do
begin
var re := minRe;
while re <= maxRe do
begin
var zr := re;
var zi := im;
var n: Integer := -1;
while n < maxIter-1 do
begin
Inc(n);
var a := zr * zr;
var b := zi * zi;
if a + b > 4.0 then
Break;
zi := 2 * zr * zi + im;
zr := a - b + re;
end;
system.out.print(chars.charAt(n));
re := re + ((maxRe - minRe) / cols);
end;
system.out.println;
im := im + ((maxIm - minIm) / lines)
end;
//Press ENTER to continue
//system.out.println("Press ENTER to exit");
system.in.read();
end;

end.

I got the code from here:
http://blog.blong.com/2011/06/project-cooper-mandelbrot-set.html

I did this:

I saved the code to a "Mandelbrot.pas" file.
I created a compile.bat script (compile.bat):

Oxygene.exe "Mandelbrot.pas" -rebuild
Pause

I then opened the Oxygene for Java command line dos prompt and navigated to the folder containing the project .pas and .bat files.

http://img138.imageshack.us/img138/8599/remobjectsoxygenecomman.png (http://img138.imageshack.us/img138/8599/remobjectsoxygenecomman.png)

Any ideas?
cheers,
Paul

pstudio
12-04-2012, 03:46 PM
I believe you should use namespace instead of unit.

Regarding the System object I believe it should be available as default but otherwise it exists in the java.lang namespace.

Unfortunately I'm not at my own computer right now, so I can't test the code myself.

paul_nicholls
12-04-2012, 09:15 PM
You were right pstudio...I had to change the code:


namespace pgd_test;

interface


type
ConsoleApp = class
public
class method Main(args: array of String);
end;


implementation


class method ConsoleApp.Main(args: array of String);
const
cols = 78;
lines = 30;
chars = " .,:;=|iI+hHOE#$-";
maxIter = length(chars);
begin
var minRe := -2.0;
var maxRe := 1.0;
var minIm := -1.0;
var maxIm := 1.0;
var im := minIm;
while im <= maxIm do
begin
var re := minRe;
while re <= maxRe do
begin
var zr := re;
var zi := im;
var n: Integer := -1;
while n < maxIter-1 do
begin
inc(n);
var a := zr * zr;
var b := zi * zi;
if a + b > 4.0 then
Break;
zi := 2 * zr * zi + im;
zr := a - b + re;
end;
System.out.print(chars.charAt(n));
re := re + ((maxRe - minRe) / cols);
end;
System.out.println;
im := im + ((maxIm - minIm) / lines)
end;
//Press ENTER to continue
//system.out.println("Press ENTER to exit");
System.in.read();
end;


end.

paul_nicholls
12-04-2012, 10:20 PM
Ok, I was able to compile the above file in the Oxygene IDE, but not via the command line version...it still can't find the system.in or system.out

I must be missing some parameters...

Well, at least my Oxygene IDE is working now :)
I would still like to see if I can get it working via command line though ;)

SilverWarior
13-04-2012, 12:28 AM
If it works trough IDE and not trough command line then it is big posibility that when using command line you don't specify proper folder locations for all necessary libraries. You should check wch parameters are usied when the project is being compiled by IDE.

paul_nicholls
13-04-2012, 01:51 AM
If it works trough IDE and not trough command line then it is big posibility that when using command line you don't specify proper folder locations for all necessary libraries. You should check wch parameters are usied when the project is being compiled by IDE.

Yeah you are probably right - I'm not sure what parameters here:
http://wiki.oxygenelanguage.com/en/Oxygene.exe

equate to the .oxygene file values though.

Anyway, I think I will leave it for now and just use the IDE.

SilverWarior
13-04-2012, 06:39 AM
I'm just guesing but wouldn't you need to use "allowimplicitout " parameter and set it to "yes" for System.Out and System.In for command line compiler to work with your code?
Othervise I would suggest for you to read through IDE documentation to learn wich parameter must be used when you are compiling your project with command line debuger.