Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: noob question about lazarus

  1. #1

    noob question about lazarus

    hi all,

    I'm a total newb to Pascal and this is my first post on these forums.


    My question is really simple. I've installed Lazarus on my computer with the required extras.

    I'm following a tutorial and the program is supposed to write some lines of text to the screen but nothing appears. What I do get is a box saying execution stopped or something like it.

    Here's the code :

    Code:
    program Kitty_Cat;
    
    begin
       Writeln('This program');
       Writeln('actually does something.');
       Writeln(' hey' );
       readln
    end.
    
    
    
    
    { Result of execution
    
    This program
    actually does something.
    
    }
    sadly the program doesn't do anything.


    Any ideas what I need to do to get the text written to the screen ?

    Thanks for any help.
    Last edited by WILL; 19-12-2010 at 08:56 PM. Reason: Put code into a code block. :)

  2. #2
    Try to run it from a command line. That should at least show something

    What platform are you on?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    did you build/compile the code before running it? Try ctrl + f9 in the program code before running. You should get a 'compiled successfully' or something along those lines message and then try running it. Also, did you make a CONSOLE program? or custom program? Lazarus gets on my nerves because it always assumes you want to make a lcl program. Which I don't. Ever.

    Edit: darn it Jsoft. Got in there right before me...
    Last edited by code_glitch; 19-12-2010 at 12:25 AM.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  4. #4
    <quote>

    Also, did you make a CONSOLE program? or custom program?

    </quote>


    Thanks for the replies guys. I think you've caught the problem there. I think I made it an application not a program so I guess that's what it was.

    I was using using Mandriva but I've since reinstalled windows because I didn't like mandriva much. Too many passwords to put in!

    I'll start the tutorials again now. Hopefully I'll get a bit further this time.

    Is it a good idea to switch from C to Pascal ?

    C was driving me nuts so I thinking that's one reason.

    Thanks again.

  5. #5
    PGDCE Developer de_jean_7777's Avatar
    Join Date
    Nov 2006
    Location
    Bosnia and Herzegovina (Herzegovina)
    Posts
    287
    Try to add the {$APPTYPE CONSOLE} directive at the top of your programs source. This will make the program compile as a console program as Lazarus by default assumes programs are GUI. Or go to Project > Project Options > Linking and untick checkbox next to "win32 gui application" or similar.

    You can get a better description of the APPTYPE directive here.
    Existence is pain

  6. #6
    Quote Originally Posted by code_glitch View Post
    Lazarus gets on my nerves because it always assumes you want to make a lcl program. Which I don't. Ever.
    Use New Project -> Program for non-lcl progs.

  7. #7
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Welcome to PGD!

    Unfortunately as everyone else has been indicating, Windows being a visual platform, doesn't bring up a command prompt (aka DOS prompt) screen for you so you won't see that it actually IS executing, it's just not showing you the text that was printed. Actually it probably did show you it just opened the prompt window and closed it so fast you could have possibly seen it.

    If you do open a command prompt it'll show it as once opened, the command prompt will stay open as an active program shell and act just like good old DOS.

    The same here can be said for programs compiled for Linux and Mac OS X as well. With the exception that Linux programs will likely keep a "terminal" (same thing as the command prompt) open after execution unless told to do otherwise as the beginning of your program.

    And yes switching to Pascal to learn concepts of programming is always a good idea. Pascal was created to teach programming and has grown to be a very strong and useful language over the many years it's been in use. After you've learned the basics of programming in Pascal you can eventually move on to learning Object Oriented Programming with Object Pascal too which brings programming to a whole new level and lets you be more organized as you make bigger and more complex programs.

    Hope some of this helps and you stick with our community. Each person asking questions and helping others makes this site all the more nicer to visit.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  8. #8
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Erm - sorry to say this will but you blundered a little. In his original code he does have a readln statement at the end... And yes, I missed it the first time - who doesn't? otherwise everything else is right on the money. As always.

    On my lazarus I would do
    Project -> New Project -> New Custom Program.
    Its the one that is NOT maintained by lazarus as I find it counter - productive for it to add code I specifically don't want there... But some people find it useful, like half of the community whom use lazarus and tell me its leagues ahead of my plain text IDEs like Geany and programmers notepad. Oh well - I gave it a few goes - it bugged my and I returned to my IDEs. Although the debugger is wonderful - don't let anyone tell you different - I find I prefer ultimate control over my code. Just like sudo mode - it just does it. No questions asked.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  9. #9
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Quote Originally Posted by code_glitch View Post
    Erm - sorry to say this will but you blundered a little. In his original code he does have a readln statement at the end... And yes, I missed it the first time - who doesn't? otherwise everything else is right on the money. As always.
    Ah right! Ok, it would pause until you hit the return key, but then it would disappear. Perhaps Vista and Windows 7 treat command prompts differently than Windows XP and previous?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  10. #10
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Nope, it would disappear. But on ubuntu if you just launch the program without $APPTYPE CONSOLE directive it never shows up in the first place - but it does create a thread that uses cpu and ram... And when you close it - the terminal window also goes. I found, in linux, either use the IDE to launch it or Ctrl + Alt + T and cd to the location the app is and do ./ProgramFile to run it in a terminal window that stays where it is...
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •