Project file question

Questions and discussion about the ZBasic IDE.
Post Reply
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Project file question

Post by rich »

So i am using a sample project file or hello world program and the file contains
--verbose
--keep-files
--list=samp.lst

No where it it that explains what these are, what they do, and other options that may be put in.

Thank you
Richard
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Project file question

Post by dkinzer »

rich wrote:No where it it that explains what these are, what they do, and other options that may be put in.
There is a section of the manual that describes compiler options, one of which is an option to specify a project file. The description of that option explains that a project file may contain, in addition to the names of the files in the project, compiler options. The compiler options are distinguished by beginning with two dashes, e.g. --verbose.

So, you'll find the descriptions of the compiler options that you named, along with all other compiler options, in chapter 10 of the ZBasic Reference manual.

http://www.zbasic.net/doc/ZBasicRef.php?page=161

It may be preferable to use the PDF version of the manual since you can search in it for the various options.

http://www.zbasic.net/doc/ZBasicRef.pdf

P.S. I just noticed that the table of contents of both the HTML and PDF versions of the manual don't match the actual content beginning with chapter 8. I'll try to get this fixed.
- Don Kinzer
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Post by rich »

Thank you much.

Also

I have two modules, so i put both names in the project file.
Does the order matter?

Given that the subs in the second module are declared public, how do i call them?
That is just the subs name or the <module name>.<sub name>?

Thanks much for your help.
Richard
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

rich wrote:I have two modules, so i put both names in the project file.
Yes. You put the names of all the modules comprising your project in the project file. If you ever have a project that includes C and/or assembly language files, those file names also go in the project file.

As described in the manual, the compiler options, generally speaking, should appear before any of the module names.
rich wrote:Does the order matter?
In most cases, it doesn't matter but it does have an effect. The first module listed in the project file is considered to be the "main" module and it must contain the Sub Main().

The names of the generated files (including, importantly, the .zxb file) are based on the name of the "main" module. So if, for example, the first named module is mytest.bas the generated executable file will be named mytest.zxb.

The other difference between the "main" module and all the others is that some Option directives may only appear in the "main" module. Read the information about the various Option directives in section 2.3.1 of the ZBasic Reference Manual.

www.zbasic.net/doc/ZBasicRef.php?page=18
rich wrote:Given that the subs in the second module are declared public, how do i call them?
You don't need to prefix the subroutine/function name with the module name (in most cases). The compiler discovers what public procedures are available among all the modules of a project and will determine which one is being invoked.

The rare case of when the module name prefix is needed would be if the main module has a private subroutine with the same name as a public subroutine in another module like this:

Code: Select all

//---- Module A.bas ----

Sub Main&#40;&#41;
   Call myTestSub&#40;&#41;
   Call B.myTestSub&#40;&#41;
End Sub

Private Sub myTestSub&#40;&#41;
End Sub

//---- Module B.bas ----

Public Sub myTestSub&#40;&#41;
End Sub
If you compile this project you would get a warning that the private subroutine hides the public subroutine but the code would compile and run correctly. Note that this arrangement is strongly recommended against but it can be done.
- Don Kinzer
rich
Posts: 81
Joined: 19 November 2015, 12:23 PM

Post by rich »

Thank you much.
Richard
Post Reply