Author Topic: Immediate Window?  (Read 5154 times)

Offline jleach

  • Single posting newcomer
  • *
  • Posts: 5
Immediate Window?
« on: October 22, 2010, 04:06:07 pm »
Hi all, TIA for any insight.  I tried searching but wasn't able to find what it was (I don't quite know what it's called).

In my VB IDE I have an Immediate Window... I can type an expression and get an answer...

-------
?1+2
3
-------

It's very limited to what can actually be done, but quite helpful in a lot of cases.

I'm very new to C++ but have found CB to be my favorite of the various IDE's that I've tried...  is there a similar functionality?  For instance, if I wanted to know what the ASCII value of "b" is, I might check it like so:

-------
?int("B")
-------


Many thanks if someone could advise.  As an alternative, I'm considering keeping a file open just to run quick checks like this in main() and output to the console, but it would be great if there's builtin functionality.

Cheers!
Jack










Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Immediate Window?
« Reply #1 on: October 22, 2010, 04:59:18 pm »
C++ is compiled language most of the time (there is a c++ script interpreter (probably more than one)  - ask your search engine where to find it).
In its compiled form, C++ doesn't support what you want and what you've used to in the VB land.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jleach

  • Single posting newcomer
  • *
  • Posts: 5
Re: Immediate Window?
« Reply #2 on: October 22, 2010, 05:09:42 pm »
Thanks oBFusCATed, I took a quick look at script interpreters but it doesn't seem to be what I was hoping for either.  I'll take your word that I won't find this particular functionality in C programming.

cheers,

Offline jleach

  • Single posting newcomer
  • *
  • Posts: 5
Re: Immediate Window?
« Reply #3 on: October 22, 2010, 05:31:21 pm »
This is a little out of the scope of the CB forum, but I figured seeing that the thread has already been started I might as well mention it in case some other newbie happened along looking for the same type of thing.

I read a few articles on attempts to "eval" an expression embedded within a string, and as stated, c++ will not support it due to the nature of the compilation.

However, if one wanted to, they could likely get similar functionality by doing the following:

1) create a template source file with an int main which has a cout << <expression>
2) create a program that opens the file, replaces <expression> with the passed string
3) automate the compiling of the file and execute it, ideally showing the expression return in the console.

The drawbacks that first come to mind doing this is including a plethera of standard libraries (a wait for compiling before you get your answer) and the limit that you could only use instristic types/objects (nothing custom), though this doesn't vary much from what the VB immediate offers.

Anyway, for one teaching themselves c++, this make make a nice little project for becoming familiar with file i/o and commandline compiling.  Thanks for the input.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Immediate Window?
« Reply #4 on: October 22, 2010, 05:36:30 pm »
If one wants to execute scripts from your C/C++ application, one embeds a scripting language (Lua for example).
There is no point in implementing such fragile systems...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jleach

  • Single posting newcomer
  • *
  • Posts: 5
Re: Immediate Window?
« Reply #5 on: October 22, 2010, 11:36:47 pm »
I took a look at Lua but admittedly I can't make much sense of it (or how I would implement it to get anything near the desired result) in the brief time I spent looking over it.  It seems as though I would have to learn a new (albeit lightweight) language to do so.

Sorry about my ignorance, this is all very new to me.  I'll look deeper into it.

Thanks,

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Immediate Window?
« Reply #6 on: October 22, 2010, 11:51:55 pm »
Lua was just an example, you can embed any embeddable language (CB uses squirrel) - python, perl, lua, haskell, probably c#+mono (Unity the game engine is using it as a script), etc...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Online stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Immediate Window?
« Reply #7 on: October 23, 2010, 02:04:51 am »
CINT is an interpreter for C and C++ code; it might do what you want, without a lot of work.
Either as an C::B Plugin or as an less likely as an user tool.

http://root.cern.ch/drupal/content/cint

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline jleach

  • Single posting newcomer
  • *
  • Posts: 5
Re: Immediate Window?
« Reply #8 on: October 23, 2010, 05:31:03 am »
Many thanks guys, it's much appreciated.  I'll look into them.

Now if only I could find a c++ forum that is at least somewhat close to as professional as this place seems to be...  :?

cheers,
Jack

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Immediate Window?
« Reply #9 on: October 23, 2010, 12:56:41 pm »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]