Compiler error on Stopped enum value using GetStatus - c++

I'm trying to get the status of a sound effect but I don't know how to actually find out what the status is. I'm quite new to C++. I tried to read up about enums and apply what I saw, but it won't work.
Here's my code
sf::Sound::Status BeepStatus = Beep.GetStatus();
cout << BeepStatus;
if (BeepStatus == Stopped)
{
Beep.SetPitch(float((rand()%15)-1)/10);
Beep.Play();
}
That code won't work. During compile it will say that Stopped is not defined. What should I do?

You need to use the scope operator for your Stopped variable.
Likely, it's this:
sf::Sound::Stopped

Related

IFS not refuses to return an array

Data
<CellA1="One">
My Problem:
I'm using a simple IF function IF(A1="One", named_range_one) and it works like charm and returned the named_range_one. But as soon as I use IFS it stops returning my named range. It seems like a bug or phrasing error for me. I also tried to wrap it into an ARRAYFORMULA but that didn't work out as well.
So IFS(A1="One", named_range_one, A1="Two", named_range_two) as soon as I use IFS my function stops working and returns the error "An array value could not be found".
I can't find a solution to this problem.
you need nested IF:
=ARRAYFORMULA(IF(A1="One", named_range_one,
IF(A1="Two", named_range_two, )))
see: https://webapps.stackexchange.com/a/124685/186471

Using Lua from C++, Fails to open standard libs with Nil error

I've been writing Lua integration into a game project, and frustratingly, every time I try and use lua_pcall, I get the error "attempting to call nil value."
When I try to look up the error, most of the examples are of people who have forgotten to use pcall after loading their lua file, or some error down the line. But for me, it's as soon as I even attempt to load the lua standard libs. I don't understand what's going wrong with so little code to show for it. Other things I've tried are skipping openLibs and going straight to loading my file with doFile, but even in that case, anything I do at all will result in a nil error.
Any help is greatly appreciated.
EDIT:
Thanks to some help I determined that I didn't need to do a pcall for luaL_openlibs, but as I wrote above, trying to run any function at all results in errors. In this case, it can't find "init" in the global lua namespace
c++
void LuaScriptingInterface::init()
{
m_luaState = std::shared_ptr<lua_State>(luaL_newstate());
luaL_openlibs(m_luaState.get());
if (luaL_dostring(m_luaState.get(), m_script.c_str())) // script below
{
const char* errStr = lua_tostring(m_luaState.get(), -1);
ASSERT(false, errStr ); // not hitting this case
}
lua_getglobal(m_luaState.get(), "init");
if (!lua_isfunction(m_luaState.get(), -1))
{
ASSERT(false); // hit this case! Why can't we find "init"?
}
}
lua
init function ()
end
update function (dt)
end
It doesn't do anything yet of course, but I expect it should at least be able to find the function.
Hilariously the issue was in my FileReader code, there was an omitted newline character

strange error in Eclipse

hello everyone I have this snippet of the code:
void* Init(int N) {
Hand * DS = new Hand(N);
return (void*)DS;
//DS is static defined somewhere...
every time when I check in Debugger I receive the same error:
mi_cmd_var_create: unable to create variable objec
can somebody please explain why?
P.S. I know that this implementation of the function is not good, but it is what I have... Constructor of the Hand works perfectly!
This guy with the same problem solved it like:
If you have variables in your watch
window that you later eliminate from
your code then attempt to debug again
this error is generated. The fix is to
also delete the variable from the
watch list. At least this is how it
works in Eclipse Europa.

What has to be Glib::init()'ed in order to use Glib::wrap?

So I'm trying to make use of a GtkSourceView in C++ using GtkSourceViewmm, whose documentation and level of support give me the impression that it hasn't been very carefully looked at in a long time. But I'm always an optimist :)
I'm trying to add a SourceView using some code similar to the following:
Glib::RefPtr<gtksourceview::SourceLanguageManager> source_language_manager = gtksourceview::SourceLanguageManager::create();
Glib::RefPtr<gtksourceview::SourceLanguage> source_language = Glib::wrap(gtk_source_language_manager_guess_language(source_language_manager->gobj(), file, NULL));
Glib::RefPtr<gtksourceview::SourceBuffer> source_buffer = gtksourceview::SourceBuffer::create(source_language);
gtksourceview::SourceView* = m_source_view = new gtksourceview::SourceView(source_buffer);
m_vbox.pack_start(*m_source_view);
Unfortunately, it spits out the warning
(algoviz:4992): glibmm-WARNING **:
Failed to wrap object of type
'GtkSourceLanguage'. Hint: this error
is commonly caused by failing to call
a library init() function.
and when I look at it in a debugger, indeed the second line above (the one with the Glib::wrap()) is returning NULL. I have no idea why this is, but I tried to heed the warning by adding Glib::init() to the begining of the program, but that didn't seem to help at all either.
I've tried Google'ing around, but have been unsuccessful. Does anyone know what Glib wants me to init in order to be able to make that wrap call? Or, even better, does anyone know of any working sample code that uses GtkSourceViewmm (not just regular GtkSourceView)? I haven't been able to find any actual sample code, not even on Google Code Search.
Thanks!
It turns out, perhaps not surprisingly, that what I needed to init was:
gtksourceview::init();
After this, I ran into another problem with one of the parameter to gtksourceview::SourceLanguageManager, but this was caused by a genuine bug which I subsequently reported and was promptly fixed. So everything's working great now!
I use gtkmm. Typically you have to initialize things with something like :
_GTKMain = new Gtk::Main(0, 0, false);
Of course do not forget :
delete _GTKMain;
Check here for details :
http://library.gnome.org/devel/gtkmm/2.19/classGtk_1_1Main.html
(Sorry but the link option does not work ...)

Error while calling member function

Hi I have just started using C++ today, and I am working on checkboxes. I have tried using CheckBox1->Checked in an if statement or whatever, but it isn't working.
The error is:
Error 2 error C2227: left of '->Checked' must point to class/struct/union/generic type
EDIT: The Code is:
void function ()
{
if (1001->Checked)
{
Sleep(2000);
}
}
Without seeing some of your code, it's very difficult to offer targeted assistance.
However, that error message usually comes about because the item you're de-referencing is not a pointer.
Check to ensure it's of the correct type. It should be something along the lines of:
tCheckBox *CheckBox1;
One possibility is that you've declared it not as a pointer to the checkbox but as a checkbox itself:
tCheckBox CheckBox1;
Note the lack of the asterisk there that would otherwise mark it as a pointer. In that case, you would use CheckBox1.Checked rather than CheckBox1->Checked, if it's allowed by the framework (this isn't standard C++ since that beast has no concept of GUI libraries).
If that doesn't help, please post the code so we can offer better suggestions.
Update:
if (1001->Checked) ?????
1001 is not a pointer - it's not a variable of any description, it's an integer constant.
You need to declare and use a variable of some description. First step is, I think, to read up on the documentation for your framework and/or get some sample code that does compile and work, basing your initial work of that.
Use CButton::GetCheck() to determine the state of the checkbox - like so...
CButton* pButton = (CButton*) GetDlgItem(IDC_CHECKBOX_RESOURCE_ID);
if ( BST_CHECKED == pButton->GetCheck() )
{
// button is checked
}