Evaluate if variable contains a value (installscript) - installshield

I defined:
STRING x; in a header (.h) file.
I have a function that I would like to check if the value x was assigned with a value, before I use it.
Something like:
if(x is null) then...
How can this be achieved in Installscript (InstallShield)?

I haven't used Installscript in years, but could you just use StrLengthChars? (example).
Resources:
The Installshield Community: https://community.flexerasoftware.com
InstallShield 2018 Help Library
Some Further Links:
InstallShield InstallScript: Strings
Using Null-Delimited Strings
Empty String comparison fails during Silent Install
IsEmpty. IsEmpty Example (Variants)

Related

Implicit string cast with potential data loss from 'string' to 'AnsiString' / ADOQuery

got here Delphi 10.3 Update 1. On the Form I have a ADOQuery which has a Field named ExtraText this field is TWideStringField .
In my Programm I assign it like this :
PrintPosQueryRack.Value:=PrintPosQueryExtraText.Value;
if I hover the cursor over PrintPosQueryRack.Value I get System.WideString
if I hover the cursor over PrintPosQueryExtraText.Value I get System.String
I really-really don't understand why . The PrintPosQueryRack is a Calculated Field , which I Created as plain string . Because I as far as I know in later Delphi versions string is Unicode (UnicodeString) in Delphi .
I also have a variable here strRack : string . If I assign it to PrintPosQueryRack.Value ( which is System.WideString ) , I get the same Warrning .
I can "fix" this by changing the strRack : string to strRack : AnsiString
and by changing the PrintPosQueryExtraText.Value to PrintPosQueryExtraText.AnsiString .
But I am kinda lost here .
Thank you .
TL;DR: Use WideString as the type for your calculated field. StringFields are internally based on AnsiString.
If you make a field of type String, (ftString), you get a TStringField. Its value is still the "old" AnsiString. This is probably for compatibility reasons.
That is, it depends on the NEXTGEN define, which basically means the for classic desktop applications TStringField.Value is still an AnsiString, while for iOS and Android apps written in Delphi, it is indeed a (unicode) String.
But that is only for the Value property. You can also use the explicit AsString, AsWideString or AsAnsiString properties. Those properties are available for any field type, but the value you give or get is translated to and from the internal type of the field. For TStringFields, that type is still AnsiString, regardless how you set the value.
For unicode values, use WideString or WideMemo fields.

Trying to add items into a ComboBox via MFC

I am trying to add items to a ComboBox so the user has a choice of what constant to run a calculation with but I cant seem to add items to a ComboBox without an error.
CComboBox *m_YM = (CComboBox *)GetDlgItem(IDC_COMBO1);
I have tried:
m_YM->AddString("Wood");
m_YM->Items->Add("Wood");
m_YM.InsertString(0, "Wood");
All throw errors. Compiler tells me that:
The argument type is incompatible with LPCTSTR.
No idea what is the meaning.
The important thing is the middle T of LPCTSTR, which means it will automatically decide if your string is Unicode or plain old ASCII, but the string needs to be input properly.
Recommended reading: What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?
Try to put an L before or enclosing inside _T(...). Example: L"Wood" or _T("Wood")

Split string in WIX Bootstrapper

I have a property named "Version" in my bootstrapper project. It contains the version as a dot separated value (1.2.3). I only need to get the last numeric value.
How to perform a string operation within this WIX bootstrapper ? Is it possible or are there any other alternatives ?
You can use Expressions.
https://www.firegiant.com/wix/tutorial/com-expression-syntax-miscellanea/expression-syntax/
For your specific condition, ENDS WITH Expression should work ( >> )

Why Visual C++ version numbers have a comma in them instead of a dot

I have seen that my Visual C++ projects have the following declarations that use COMMAS instead of DOTS for versions:
#define FILEVER 11,0,2,0
#define PRODUCTVER 11,0,2,0
#define STRFILEVER "11, 0, 2, 0\0"
#define STRPRODUCTVER "11, 0, 2, 0\0"
The MS article here also has the same values with commas (actually the above declarations are based on that article). Why are we using COMMAS here? When I open the compiled file properties, I see FileVersion as 11.0.2.0 but ProductVersion as 11,0,2,0 - for which my QA friends say that its a bug :). Is there some standard or maybe some internal mechanism that I am missing?
In the first two definitions because Microsoft resource file syntax calls for commas. For the later two definitions the Microsoft convention sticks to commas there too. Microsoft wants to differ, probably.
The file version is taken from the non-string variant and gets printed with dots in file explorer. The product version gets taken from the string. You could probably write the string with dots yourself. It's a string, it shouldn't matter. But you'll have to edit the .rc file manually—Visual Studio will write commas.
As for the first two definitions, I can see reason for choosing commas in general C++. If you had 11.0.2.0, it would be syntax error in about any context and the only thing you could do is convert it to string with the # operator. But with commas, you can expand it to definition of array or structure. Like int version[] = { 11,0,2,0 };. That's useful if you want to have version check in code.

How do you convert a character to a key value in XNA

I'm trying to convert a character that I have specified in my application configuration file to a XNA keyboard key. How would I parse my character value to a key?
While harryovers has given you an exact answer to your question, perhaps a better solution for configuration files is to convert from a string instead of from a character. That way your configuration file may specify any key by name, not just alpha-numeric ones.
You could use Enum.Parse to convert the string to an enumeration (MSDN, example).
this should work:
char c = 'a';
Keys cAsKey = (Keys)((int)(char.ToUpper(c)));
bool compareKeys = (cAsKey == Keys.A); //true
If you're targeting Windows, take a look at the KeysConverter class in System.Windows.Forms. Technically XNA Keys != Windows Forms Keys, but internally they use the same integer values.

Resources