Page 1 of 1

Project file

Posted: 26 November 2018, 9:28 AM
by rich
The files to be compiled are entered into the project file but do they need to be module files or could they just be files with code in them?

Thanks
Richard

Re: Project file

Posted: 26 November 2018, 13:05 PM
by dkinzer
rich wrote:[...]could they just be files with code in them?
Any file containing ZBasic code (subroutines, functions, data declarations, etc.) is considered to be a module. (And, by the way, you can't have ZBasic executable statements that are not contained within a subroutine or function.) The module containing the Main() subroutine is considered to be the main module and must be first on the list of files to compile.

If need be, you can also include C and AVR assembly language files in the project file when compiling for a native mode target device. Generally speaking, those files should be named in the project file after all of the ZBasic code files. You could intermix the C and assembly language files with the ZBasic code files but there is no good reason to do so.

To summarize, the project file may consist of the following elements (generally speaking, in the order mentioned below):
  • * optionally, compiler directives and compiler options
    * ZBasic modules (of which the main module must be first)
    * optionally, C and/or AVR assembly language files

Posted: 26 November 2018, 15:37 PM
by rich
Now i know my misunderstanding.
I thought that "module" was a key word.

However it sounds like it is just a file with code in it and the first file in the list must have the sub main in it.

Is this correrct?
richard

Posted: 26 November 2018, 16:41 PM
by dkinzer
rich wrote:I thought that "module" was a key word
Actually, it is. For compatibility with Visual Basic, you can specify the keyword Module followed by the module name. However, since that module name must match the module name derived from the filename, it serves no useful purpose.
rich wrote:it sounds like it is just a file with code in it and the first file in the list must have the sub main in it.
That is correct. Section 2.3 of the ZBasic Reference Manual describes what modules are.

www.zbasic.net/doc/ZBasicRef.php?page=18