I tried this because I want to learn how to grab a machine unique ID.
I need it because I'm gonna code a program that reads the machineid and compares it to a specific one.
I edited the code(in the end, the code that prints the Machine ID) to this:
string MachineID;
MachineID = vtProp.bstrVal;
if (MachineID == vtProp.bstr)
but it only gives me this error.
How would I make my HWID variable be set to the value of vtProp.bstrVal, then compare it with vtProp.bstrVal? I've googled for some hour now, can't seem to get it fixed.
Thanks in advance!
Simple syntax error - you've used =, which is assignment, instead of ==, which is comparison.
Because c++ accepts nonboolean types in if statements, the code if(variable = value) is acceptable to the compiler, which tries to assign MachineID the value of vtProp.bstr, which causes your error due to type mismatch.
Related
I am getting this error while Deserializing an object in AX. To make it more weird its fine in my local but failing in other.
str sampleString = conpeek(nodeData, 1);
JArray jArray = JsonConvert::DeserializeObject(sampleString );
I just had this same issue. I don't know if your issue is the same as mine, but in my case, it was coming from an attempt to grab a boolean value from a deserialized container. It would work when running from the AX client, but didn't work when running from CIL. (CLR stuff sometimes behaves differently running locally vs on the server in CIL.) Solved the issue by grabbing the value as a string, then converting to boolean.
My code works perfectly in simulator, but it pops this "fatal error: unexpectedly found nil while unwrapping an Optional value" warning when I tried to run it on my iPhone and iPad.
Strange thing is, this error didn't occur when I tried to get the value of a variable, it happened when I tried to create an object with the values I got:
"pName" and "pQuestion" are the variables with values, but as you can see, once I tried to give these value to the attributes of my object, they just became nil.
This bit of the code really behaved in the simulator, somehow it just keeps acting out on a real device.
What Swift is telling you is totally correct. Your question variable is nil when you are assigning values to it.
Don't you wanna initialise it before you start putting values into it?
I think what you are looking for is
let question = Question(name: pName, question: pQuestion)
So, I think I know whats wrong with my code.
Like Hunaid Hassan said, my current code will just get nil out of the object.
The reason my original code didn't work is because, one of the attributes is a Date variable, and because I'm in Australia, when the app runs on a real device the Date I get will be nil because I didn't set the locale.
Here's my original code:
enter image description here
And here's the fix I found to set the locale:
enter image description here
ref: https://stackoverflow.com/a/26154583/7578872
I want to use vtkArrayCalculator, for use in a Paraview filter, as described here: ArrayCalculatorExample
vtkSmartPointer<vtkArrayCalculator> calculator = vtkSmartPointer<vtkArrayCalculator>::New();
calculator->SetInputData(input);
calculator->AddScalarArrayName("u");
calculator->SetFunction("u+1");
calculator->SetResultArrayName("wind_velocity");
calculator->Update();
vtkSmartPointer<vtkFloatArray> windVelocity =
vtkFloatArray::SafeDownCast(calculator->GetStructuredGridOutput()->GetPointData()->GetArray("wind_velocity"));
Now when I want to access the data with (or similar commands)
windVelocity->GetValue(0);
I get a "Segmentation fault (core dumped)".
"input" is a vtkStructuredGrid and "u" is a vtkDataArray (that can be downcast to a vtkFloatArray without problem). "u" can be accessed by
input->GetPointData()->GetArray("u");
Every hint to what I am doing wrong is greatly appreciated!
Edit: I already tried the following
vtkSmartPointer<vtkFloatArray> windVelocity = vtkSmartPointer<vtkFloatArray>::New();
windVelocity->DeepCopy(vtkFloatArray::SafeDownCast(calculator->GetStructuredGridOutput()->GetPointData()->GetArray("wind_velocity")));
I'd suggest to split up the long chain of vtkFloatArray::SafeDownCast(calculator->GetStructuredGridOutput()->GetPointData()->GetArray("wind_velocity")) and use a debugger to see what the intermediate results are.
When reading the definition of GetArray, it states that under various conditions the function might return NULL. Check the return value of GetArray; it is very likely that you do not get back what you expect.
vtkDataArray* vtkFieldData::GetArray ( const char * arrayName )
inline
Not recommended for use. Use GetAbstractArray(const char *arrayName) instead.
Return the array with the name given. Returns NULL if array not found.
A NULL is also returned if the array with the given name is not a
vtkDataArray. To access vtkStringArray, vtkUnicodeStringArray, or
vtkVariantArray, use GetAbstractArray(const char *arrayName).
In my database, there are a lot of options where an entry ISNT required at start, so it is nullable. I was looking through the C++ api for SQLite3 and i didnt find anything from first glance ( http://www.sqlite.org/c3ref/funclist.html) as to how to handle this. The only thing i came across was what is returned when you request a column and the column is null (shown here: http://www.sqlite.org/c3ref/column_blob.html).
The thing is that, might not be throing errors because 0 is a valid solution for a lot of common things (As a programmer we usually start counts at 0).
What i want to do is find a boolean statement if there is one, so that way i can check if null before extracting the data. That way, a proper flag can be returned instead of 0.
Anyone else have issues here?
You can always check the type of the column before getting the data (which will do a conversion). You do it with sqlite3_column_type, which returns SQLITE_NULL for a NULL value:
bool isNull(sqlite3_stmt *stmt, int iCol)
{
return sqlite3_column_type(stmt, iCol) == SQLITE_NULL;
}
I have a windows mobile 6 application using TAPI 2.0. lineGetAddressID() is needed to get the address identifier used by several calls in the telephone api, but I can't get it to work.
I have tried the following to no avail:
HLINE line; // valid handle from lineOpen();
DWORD addr_id = 0;
result = ::lineGetAddressID( line, &addr_id, LINEADDRESSMODE_DIALABLEADDR, L"1234", 5 );
result = ::lineGetAddressID( line, &addr_id, LINEADDRESSMODE_DIALABLEADDR, L"5551234", 8 );
result = ::lineGetAddressID( line, &addr_id, LINEADDRESSMODE_DIALABLEADDR, L"1115551234", 11 );
result = ::lineGetAddressID( line, &addr_id, LINEADDRESSMODE_DIALABLEADDR, L"11115551234", 12 );
All of them return LINEERR_INVALADDRESS. Can anybody point out what I may be doing wrong?
As a side question, how can I programmaticly get the address? It appears in the LINEADDRESSCAPS structure returned by lineGetAddressCaps(), but that requires an address identifier (which would need to come from lineGetAddressID(), which requires an address...).
Note: I realize I could use 0 as the address ID and it will probably work, but I have no guarantee it will work for every platform. I would like to get this solved 'right'.
Thanks,
PaulH
When you invoke lineGetDevCaps one of the members of the LINEDEVCAPS structure, dwNumAddresses, is a count of the number of addresses associated with the line device.
TAPI states that the value of address identifiers are defined as the following:
Address identifiers range from zero to one less than the value indicated by dwNumAddresses.
So you can iterate through each address identifier value in the range [0 .. (dwNumAddresses - 1)] and invoke lineGetAddressCaps as you have provided a valid address identifier. There is no need to use lineGetAddressID in this case as the address identifier is known and valid.
If you do this, do any of the addresses specified in the LINEADDRESSCAPS structure match the string being used in your calls to lineGetAddressID? Noting that your application is configured to use Unicode rather than ANSI.