Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: jleach 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
-
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.
-
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,
-
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.
-
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...
-
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,
-
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...
-
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.
-
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
-
http://stackoverflow.com/ ?