Expected expression error assigning value in Objective-C - objective-c

I am a new Objective-C programmer and I am working on a project.
I created a function which returns a float value and I declared some variables into it as shown here :
-(float)WN8Calculation{
int avgDAMAGE,avgFRAGS,avgSPOT,avgDEF,avgWIN;
long battles;
double expDAMAGE,expFRAGS,expSPOT,expDEF,expWIN;
double rDAMAGE,rFRAG,rSPOT,rDEF,rWIN;
float rDAMAGEc,rFRAGc,rSPOTc,rDEFc,rWINc;
float wn8;
int tank_id;
avgDAMAGE =2;
return wn8;
}
When I assign the value for the variable avgDAMAGE I get an error in that line saying "expected expression". Can someone help?

Well i solved this error (i guess) what i had to do is to just delete the line a rewrite it..
Thanks for your help guys.

Related

WxWidgets CheckListBox getting value issue

I have a problem with WxWidgets version 3.0.2. Currently I'm trying to get the value of a 'ChecklistBox' with index number 0.
It seems to work, however I can't get it to fill a string variable from C++.
I tried a lot of things, such as .ToString(), .mb_str(), (string)varname, etc.
The code I am using to get the value which I presume works, but returns a non 'string' result, so I can't use it in my C++ code... (at least not yet..)
The Code I use to get the value of index number 0 returns no errors:
CheckListBox = new wxCheckListBox(this, CHECKBOX1, wxDefaultPosition, wxSize(208,63), 0, 0, 0, wxDefaultValidator, _T("CHECKBOX1"));
CheckListBox->GetItem(0); //Seems to work (at least gives no errors)
String Test = CheckListBox->GetItem(0); //Fails
Error returned: conversion from ‘wxOwnerDrawn’ to non-scalar type std::__cxx11::string {aka std::__cxx11::basic_string}|*
Simple test such as the following work since I see 'Test' added to the CheckListBox:
CheckListbox->Check(CheckListBox->Append("Test"));
Thanks for any advice!
I can't see GetItem(idx) in CheckListBox.
Perhaps you are looking for virtual wxString GetString (unsigned int n) const which is inherited from wxListBox.

Convert type* to type: cli::array>type,1>^

I need help converting a parameter of type
double* testVar
to a parameter of type
array<double> ^%parentVar.
I`m still trying to learn CLI C++ so this might be quite easy but I don't seem to figure it out.
Regards
Based on #Alex Farber comment the answer to this question is:
double *testVar; // This testVar takes a value from a function that I will not post here
int vectSize = 10;
array<double>^ TempVector= gcnew array<double>(vectSize);
Marshal::Copy(IntPtr(testVar),TempVector,0,vectSize);
parentVar=TempVector;
That was all!

WritePrivateProfileString with int variable as value

I'm quite new to C++.
Right at the moment I'm trying to write and read an ini file. As I'm working with VS 2010 I d'like to use the WritePrivateProfileString function.
testwise it works like this
WritePrivateProfileString("testsection","testkey","testvalue","testfile.ini");
I can run this successfully.
My idea now is to hand overthe value within a variable of course which represents an int value.
WritePrivateProfileString("testsection","testkey",testvalue,"testfile.ini");
I understand that I would have to cast it first to LPCSTR or char so it works.
int testvalue =12;
WritePrivateProfileString("testsection","testkey",intToChar(testvalue),"testfile.ini");
//convert int to LPCSTR
char* intToChar(int temp){
char wert[8];
itoa(temp, wert, 10);
cout << wert;
return wert;
it does write to the file. but instead of a number i get random signs like "<º-" and stuff.
I've been trying for an hour now. Using different convertion (to LPCSTR, to char, to string) without any success.
what am I doing wrong? I really stat to get desperate.
thanks for any hint.
}
WritePrivateProfileString function can handle only "string", not "Integer Value".
You can make string from integer using itoa().

Multi map insert

I am trying to pass 6 values instead of a value.
//function that contains the value
siteNEVObjectdic::siteNEVObjectdic(double iLat1, double iLong1, double iLat2, double iLong2, double iLat3, double iLong3)
{
Lat1=iLat1;
Long1=iLong1;
Lat2=iLat2;
Long2=iLong2;
Lat3=iLat3;
Long3=iLong3;
}
multimap<double,double> dic;//initialization
dic.insert(pair<double,double>(2,gcnew siteNEVObjectdic(Lat1,Long1,Lat2,Long2,Lat3,Long3));
for some reason it is,
error C2665: 'std::pair<_Ty1,_Ty2>::pair' : none of the 3 overloads could convert all the argument types
giving me this error. any help will be appreciated.
You're creating a pair but trying to push a siteNEVObjectdic object in as the second entry. Try,
multimap<double,siteNEVObjectdic> dic;//initialization
dic.insert(pair<double,siteNEVObjectdic>(2,siteNEVObjectdic(Lat1,Long1,Lat2,Long2,Lat3,Long3));

WxWidgets using wxString

I'm taking a computer sciences class and we have to make a calculator using a GUI. I have been banging my head into a wall trying to even get input though.
Understand how to use pointers and GetValue(), to take in the input as a wxString but that does me no good, If I can't get the string as a double or integer then I can't perform operations on it.
Does anyone know how to convert wxString to Double? or even int?
Thanks in Advance
For this purpose, there are the two functions ToDouble and ToLong.
For details take a look at the offical documentation:
http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringtolong
http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringtodouble
EDIT: Example:
wxTextCtrl ctrl;
// user has entered a number
double number;
if( !ctrl.GetValue().ToDouble( &number ) )
// handle error
else
// continue...
Please note: It will only work if you enter a number. If you enter a term like 2+3 the function should return false. In this case you have to split the string up and interpret all numbers seperately.