• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS20 Reading an aircraft string using execute_calculator_code issue

Messages
162
Country
italy
This piece of code, that will be compiled as wasm, does not return ATC _ID as should do:
Code:
PCSTRINGZ barcode;
execute_calculator_code((PCSTRINGZ)"(A:ATC ID, string)", (FLOAT64*)NULL, (SINT32*)NULL, &barcode);
barcode is unreadable..
Any clues ?
Thanks in advance
/Mario
 
It is not a PCSTRINGZ... it's 64-bit code for MSFS2020 and that probably means wide characters... like WCHAR
 
Thanks for answer,
at least has such declaration in gauges.h:
Code:
BOOL FSAPI execute_calculator_code(PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);
using std:wstring or any other WCHAR object won't compile.
Do you have any working example using wide chars strings ?
 
All I can offer is that what you are describing sounds like a WCHAR* being referenced as a char*... I know that in P3D v4 (the 64-bit), it was changed from PCSTRINGZ to LPCSTR which isn't a wchar... BUT... the results you're saying you are getting remind me of a WCHAR* being referenced as a char*.
 
Thanks,
however also in p3d v5 execute_calculator_code has the same signature as above, moreover same code works flawlessly in P3D 64 bit.
/Mario
 
I probably shouldn't have mentioned P3D... creates confusion and it's not even the same code path. Try to cast the returned pointer value as a WCHAR* and see if it makes a difference.
 
I have also receive empty string "\0" for every variable from Aircraft String Data and also from some another having Units string.
SimVar watcher example from SDK doesn't have string units and that is strange.
I think that lack of XML explanation in SDK documentation can't explain what execute_calculator_code can and can not do in MSFS with strings.
 
Hello,
same thing happens with:
Code:
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "TITLE", NULL,SIMCONNECT_DATATYPE_STRINGV);
SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_1, DEFINITION_1, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_ONCE);
.....
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
      {
        SimConnect_RECV_SIMOBJECT_DATA *pObjData = (SimConnect_RECV_SIMOBJECT_DATA*)pData;
           switch(pObjData->dwRequestID)
        {
          case REQUEST_1:
                   char* pS = (char*)&pObjData->dwData;
            break;
        }
      break;
      }
returns a void string for all aircraft string with no exception, while works nicely on other data types.
 
Variable length strings have to be processed differently than static length strings. You have to use SimConnect_RetrieveString to process a variable length string.
 
If you're doing this in MSFS2020... then it's probably non-functional, like most of the SDK for aircraft support.
 
Thanks,
as suspected from MSFS 2030 SDK:
String SimConnect_RetrieveString Bad response Returns empty strings (either a data or server problem)
/Mario
 
Back
Top