BBC BASIC for Windows
IDE and Compiler >> Compiler >> Calling the Compiler from the Command Line
http://bb4w.conforums.com/index.cgi?board=compiler&action=display&num=1226262531

Calling the Compiler from the Command Line
Post by mohsen on Nov 9th, 2008, 7:28pm

Well, the first thread in this section smiley

Is there a way to call BB4W Compiler from the command line to take a BASIC file compile it and save it without opening the IDE window?

i.e. something like:

BBCWIN.exe "in_filename" /c ["out_filename"]

There is no need to pass Compiler parameters (options) as these can be embedded as REMarks in the program file itself.

The out_filename can also be embedded as a REMark statement.

Thanks


Re: Calling the Compiler from the Command Line
Post by admin on Nov 9th, 2008, 9:43pm

Quote:
Is there a way to call BB4W Compiler from the command line

It's something I have considered (no. 207 in my list of nice-to-have features: "command-line compilation utility"), but have never gone so far as to implement it.

There would be issues like how to indicate the location of a compile error, since at present it relies on being able to highlight the problem statement in the editor.

It's certainly not a trivial task, especially if you wanted a genuine console program (for example all the existing 'compilation' code assumes it's OK to display a MessageBox if it's necessary to alert the user).

Richard.
Re: Calling the Compiler from the Command Line
Post by mohsen on Nov 10th, 2008, 09:50am

on Nov 9th, 2008, 9:43pm, Richard Russell wrote:
It's something I have considered (no. 207 in my list of nice-to-have features: "command-line compilation utility"), but have never gone so far as to implement it.

There would be issues like how to indicate the location of a compile error, since at present it relies on being able to highlight the problem statement in the editor.

It's certainly not a trivial task, especially if you wanted a genuine console program (for example all the existing 'compilation' code assumes it's OK to display a MessageBox if it's necessary to alert the user).

Richard.


Thanks Richard.

I hope that you re-consider this utility/feature.

An error may be generated by throwing it out to the console mode and existing the Compiler.

Surely a flag (indicating in IDE or in Console Mode) could be setup to indicate to the Compiler if to display an error box or not.

In console mode, Complier should exit/terminate immediately when encountering the first error. It is not necessary to parse the entire BASIC file for Compile errors.

The user calling the Compiler this way can easily check if the Compile function failed or succeeded by examining the presence of the "out_file". If no "out_file" generated by complier then Compile has failed.

It is also possible, in the case of a Compile error, to generate the "out_file" as a ".txt" file instead of an ".exe" file with the first line reading (for example):

BB4W Compile Error: <Error Message>


Just some simple ideas wink.

Thanks again.


Re: Calling the Compiler from the Command Line
Post by admin on Nov 10th, 2008, 10:54am

Quote:
Just some simple ideas

I don't have the time, resources or motivation that would be required to implement such ideas and test them thoroughly.

I had hoped that you would agree that displaying a MessageBox from a console program was acceptable (even CMD.EXE itself does it: try copying a file to a write-protected floppy!); that might allow a 'quick and dirty' command-line compilation utility to be created. If not I'm afraid it's out of the question.

Richard.
Re: Calling the Compiler from the Command Line
Post by mohsen on Nov 10th, 2008, 12:59pm

on Nov 10th, 2008, 10:54am, Richard Russell wrote:
I don't have the time, resources or motivation that would be required to implement such ideas and test them thoroughly.

I had hoped that you would agree that displaying a MessageBox from a console program was acceptable (even CMD.EXE itself does it: try copying a file to a write-protected floppy!); that might allow a 'quick and dirty' command-line compilation utility to be created. If not I'm afraid it's out of the question.

Richard.


I didn't get it ?


Re: Calling the Compiler from the Command Line
Post by admin on Nov 10th, 2008, 2:05pm

Quote:
I didn't get it ?

Console-mode programs can display Message Boxes, Dialogue Boxes, indeed any of the usual Windows GUI controls, it's just that they don't normally do so.

It would be a lot easier (and safer) for me to create a command-line compiler utility if I could leave the warnings and error messages just as they are now - i.e. by means of a MessageBox. Despite being a console program that is perfectly possible.

Indeed, I'd probably have to display a dialogue box too, because all the compiler settings are read from the 'Compile' dialogue box.

My reference to CMD.EXE (and COMMAND.COM) - the programs that display a command prompt in a DOS-like console window - was that they too display warnings in a MessageBox in some circumstances, such as when attempting to copy a file to a write-protected floppy.

My suggestion is that if Microsoft consider that acceptable for CMD.EXE and COMMAND.COM, it ought to be acceptable (if somewhat non-standard) for a BBC BASIC compile utility too!
Re: Calling the Compiler from the Command Line
Post by JGHarston on Aug 6th, 2010, 3:26pm

I compile BBFW programs with my Make utility, which could be thought of as command-line compilation.