Author Topic: Terminal window  (Read 31132 times)

Offline nime1

  • Multiple posting newcomer
  • *
  • Posts: 22
Terminal window
« on: March 18, 2010, 10:13:35 am »
Hello,

First q:
How to get terminal window to open when I run program through IDE so I can print to them during program execution?

Second q:
Is here some command like "RunningInIDE" so I can get functions which will be disabled when file would be standalone?
Like this:

If (RunningInIDE)
    printf("This is item %d"), i);

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Terminal window
« Reply #1 on: March 18, 2010, 11:20:42 am »
If (RunningInIDE)
    printf("This is item %d"), i);
This can only work with interpreted languages, like VB for example. I C++ this is technically not possible. But you can just use a default / release target for this purposes. Within debug, set a #define accordingly to include the debug statements, while in release mode (target) this is just ignored by the compiler.

It seems you do a switch from a language (VB I guess) to C++. You should start with forgetting everything you know / expect from VB and learn new from scratch.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline nime1

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: Terminal window
« Reply #2 on: March 18, 2010, 11:30:45 am »
 :D Morten, You have absolutelly right and you guess fully!
I still noticed that after many years i am at beginning  :shock:

OK, regarding first question?
Note: I allready have xterm -T $TITLE -e in my Enviroinment settings but terminal here dont appear with starting a programm. Interesting is that I have some downloaded samples which opens a terminal. I look to all settings in them but I cant find "quirk".

Any idea?


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Terminal window
« Reply #3 on: March 18, 2010, 12:25:42 pm »
Any idea?
Check your project properties, if it is a "console application" (otherwise there will never be a console) and you have enabled "Pause if execution ends" on the "build target" tab. Probably the console opens, but just closes too quickly.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline nime1

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: Terminal window
« Reply #4 on: March 18, 2010, 12:45:58 pm »
Thats exactly what I am looking for.
Thank you wery much. Works perfectly  :D!

haroldo

  • Guest
Re: Terminal window
« Reply #5 on: July 24, 2010, 11:31:22 pm »
Dear CB users/devs,

I'm having this problem with C::B 10.05

Checked all solutions posted in this thread (and in other threads too :( ), but still without the ability to run console applications.
If run run in debug mode (F8), everything runs fine.

My problem is just with the option Build->Run.
Tried xterm, gnome-terminal and roxterm.

The problem started after I upgraded to 10.05.

Any help would be greatly appreciated.

Thanks,

Haroldo

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Terminal window
« Reply #6 on: July 25, 2010, 03:11:08 pm »
Second q:
Is here some command like "RunningInIDE" so I can get functions which will be disabled when file would be standalone?
Like this:

If (RunningInIDE)
    printf("This is item %d"), i);


What about an environment variable that you set in Code::Blocks that the RunningInIDE method would check for? Running the program through the IDE should give you that variable, while running it outside the IDE would not (unless you explicitly add it to your OS or terminal session).