Jump to content
Excelsior Forums
oo

Executable Does not Output Anything

Recommended Posts

Hi,

I am compiling some old TopSpeed Modula 2 Code with the XDS Compiler. I compiled the individual modules after making some modifications and they compiled. I then compiled the Main Module ? and got the executable. However, when I run the exe ? I simply get a blank screen. The program does not crash or anything ? but I get nothing there.

The beginning of the program does absolutely nothing other than write some text to the screen and then wait for the user to input the name of a file. So I copied the first 2 lines from the program (in addition to some include statements) into the ?Hello World? example that you have ? I compiled this with the same flags that I compiled my program. This ?Hello World? seemed to output the text ? however the executable does not seem to be able to do it i.e. it has a blank screen.

Does anyone have an idea what I might be doing wrong?

I then deleted all of the lines in the original Module and just put in something like

IO.WrStr("Hi?);

I compiled it ? but still I don?t get any output?

Any ideas??

Thanks a lot to you guys.

O.O.

Share this post


Link to post
Share on other sites

I would just like to add that by deleting the big number of imports at the top of the file ? then it obviously works as expected i.e. outputting the Hi. But why would using imports cause it to output nothing.

O.O.

Share this post


Link to post
Share on other sites

Please check if there is the module WINDOW on the import list. This module provides window management in the text mode. It redirects the IO's output from the console to an active window while its initialization. (See IO.WrStrRedirect for details.) As soon as you include the module WINDOW into your program, IO will work with the active window. Try to remove WINDOW from the import list for all your modules.

Share this post


Link to post
Share on other sites

Thanks sleepyhead for your faithful responses.

So you mean I should put:

IMPORT WINDOW;

In the import statements that I already have in my program. Right now it does not have this ?IMPORT WINDOW;? anywhere in any of my modules. Also when I do this I get the following error:

* [DECMAIN.MOD 15.14 F194]

* module name does not match symbol file name "WINDOW"

IMPORT WINDOW$;

Thank you for your help.

O.O.

Share this post


Link to post
Share on other sites

Quite the contrary, I suggested to remove the module Window from the imports. :-) Well, if your program does not import this module at all... Sorry, at the moment I have not idea why the program displays a blank screen after startup.

Share this post


Link to post
Share on other sites

Dear sleepyhead,

I have found that if I include any other module other than IO i.e. any one of my personally created modules, I get no output when the only line in my program is IO.WrStr("Hi?); I don?t see how importing unused modules should cause different program behavior. Is this a bug??

Also I get a blank screen when I double click on the executable in windows ? but when I run it from the command prompt, I simply get a single blank line.

Thanks for you help.

O.O.

Share this post


Link to post
Share on other sites

A bug? :-\ It seems to help you we need to reproduce the problem by ourselves. Could you please reduce your program as small as possible still to reproduce the problem and post it here?

Share this post


Link to post
Share on other sites

I don?t see how importing unused modules should cause different program behavior. Is this a bug??

Import is use, so there is no such thing as "imported unused module".

More specifically, an imported module is initialized (i.e. its body is executed) regardless of whether any entities exported from it are referenced in the importing module.

Share this post


Link to post
Share on other sites

Dear sleepyhead and snowman,

Thanks for responding. I am not familiar with Modula 2 ? so take my descriptions and discussions with that in mind. I might just be missing something obvious.

I have noticed that if I import modules into my main module ? the main module does not print out anything. Now, snowman seems to say that the body of the imported module gets initialized.

What is body? I am not sure if I understood this. My main module does have a body in the sense it has a BEGIN and END statements. My other modules are defined as ?IMPLEMENTATION MODULE module_name;? at the top ? and do not have a BEGIN statement i.e. they just define a bunch of procedures. So where is the initialization??

Yes, I can provide you a sample ? but first I would like to know what gets executed in the ?Implementation Modules?? I am asking this question, because importing these changes the way my program executes.

Thanks a lot.

O.O.

Share this post


Link to post
Share on other sites

Hi,

In addition to my previous post above, I tried stepping through the program using the debugger. It seems that it first starts with the BEGIN statement in my Main Module. Then it executes the END statements in the ?Implementation Modules??? After it gets through all of the END statements in the ?Implementation Modules? it starts executing the real program i.e. to output a string to the console.

So I am still clueless to what exactly gets executed in the ?Implementation Modules???

O.O.

Share this post


Link to post
Share on other sites

The initialization code for all implementation modules is executed before the start of the main program. If a module uses some others (i.e. it has IMPORT clause), all modules that this module depends on are initialized before its own initialization code is executed. So, even if a module has not its body (BEGIN..END part), the compiler generates the special 'hidden' code to call the initialization code for all imported modules, but, really, you needn't know this magic except that the order of initialization cannot be guaranteed.

What about reading Modula-2 tutorial?  ;) Take a look at http://www.modula2.org/tutor/index.php

Share this post


Link to post
Share on other sites

Dear sleepyhead,

Actually none of my modules other than the Main Module have a body. Each of them define functions. So when they import each other ? as none of them have a body, nothing should be executed. Consequently, the program should not be affected.

However for me the program does get affected. This is what puzzles me. As I mentioned in my post above, I stepped through it with the debugger ? and I could not find anyline getting executed other than the END statements in each of the remaining modules.

O.O.

Share this post


Link to post
Share on other sites

Good Question snowman,

I did not think of this. However, I did not expect some library modules to screw things up. Below I am trying to make a list of some of the Library Modules that my Modules in totality import:

IMPORT Str;

IMPORT IO;

IMPORT BiosIO;

FROM Lib IMPORT Exec, GetTime;

FROM FIO IMPORT Open, File, Close, WrStr, WrLn, RdChar, RdStr,RdCard,WrCard, Create;

FROM Storage IMPORT ALLOCATE,DEALLOCATE;

I think this is all ? but there may be more. I am not sure if I missed any though.

O.O.

Share this post


Link to post
Share on other sites

Hi,

I just wanted to add this ? if it would help.

Though I have a number of modules, I have not specifically created a ?project? per se. I simply compile the Main Module with the other modules in the same folder ? and the XDS Compiler generates the object files for each of the other modules, and then the executable file for the Main Module. Is this the wrong way to do this??

I am compiling the main module with the following at the commandline:

xc =m -WOFF+ +STORAGE +topspeed +m2addtypes +M2EXTENSIONS OMAIN.MOD

where OMAIN.MOD is the name of my Main Module. Is this OK?

O.O.

Share this post


Link to post
Share on other sites

XDS User's Guide: In the MAKE mode the compiler determines module dependencies using IMPORT clauses and then recompiles all necessary modules. Starting from the files on the command line, it tries to find an Oberon-2 module or a definition and implementaion module for each imported module. It then does the same for each of the imported modules until all modules are located. Usually, a Modula-2 program module or an Oberon-2 top-level module is specified on the command line. In this case, if the LINK equation is set in either configuration file or xc command line, the linker will be invoked automatically in case of successful compilation. This feature allows you to build simple programs without creating project files.

So, you do all right.

Share this post


Link to post
Share on other sites

You can catch a lion in a desert by a binary search.

HelloWorld works fine for you. Add only half of your modules into your project. Or, better, import only one module into your main module (of course, then you have to comment out some piece of code). Compile and run. Does it work as expected? If yes, add another module and try again. Annoying? Well, but it should help.

Share this post


Link to post
Share on other sites

Dear sleepyhead,

I hate to be telling you this ? because actually in your very first post ? you had suggested that I do this.

I had the module WINDOW in one of the Implementation Modules. This screwed things up Big Time.

I can swear that I searched all of my modules ? but I don?t know how I did not catch this. I guess the first time I searched through the Windows Explorer telling it to search for the text in all of the files in the compilation directory ? this did not work, because it somehow recognizes the MOD files as some kind of movie files and considers them binary. I then searched using a text editor ? but then my import had ?Window? instead of WINDOW (which I copied from your post) ? and I missed it again.

Yes, I do get the output on the screen ? but now my program crashes somewhere. I would have to spend time debugging it now.

Thank you for your persistent help.

O.O.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×