Generate multiple executables with 1 different variable value MVS C# - c#

I'm making a program which contains a string key variable which should be different for each executable that I generate.
I have a list of 50 string key values which I want to use for 50 .exes.
What's the best way to do this?
I'm using C# in Visual Studio.
Thanks in advance
EDIT:
static string key = "X";
This line of code is in my project. Now I want to generate 50 exes where I replace the X with another value.

The best way would be to have a command-line argument which fills your key-variable, so you'd only have 1 executable and 50 links to it.
Using 50 .exe-files you could use pre-processor conditions to set different values for key and a batch-file which calls csc.exe with 50 different variables.
But that all sounds strange. May you have some base-problem, which could have simpler solutions? Think of the XY-Problem. If its so, consider posting a new question.

Related

MQL_DLLS_ALLOWED cannot be set

I want to know if there is any way to set the property id values of the ENUM_MQL_INFO_INTEGER using external program or dll or anything.
I tried this:
int OnInit()
{
//---
MQL_DLLS_ALLOWED = 1;
Print(MQLInfoInteger(MQL_DLLS_ALLOWED));
//---
return(INIT_SUCCEEDED);
}
It gave error:
'MQL_DLLS_ALLOWED' - l-value required TestingEnum.mq5 15 4
'1' - cannot convert enum TestingEnum.mq5 15 22
'=' - l-value required TestingEnum.mq5 15 21
Kindly, let me know what I can do.
I cannot help you with your question directly, mainly because of the reasons discussed in the comments. I believe you can check the value whether DLL is allowed, but you cannot enable/disable it easily. Maybe there is a way with running MT terminal from the command line, with some keys allowing or blocking dll, so you may check. But that means restarting your platform, I am not sure that is convenient.
If I were you, and tired of enabling/disabling dll dozen times, I would introduce a global variable of client terminal, with values 0 or 1 (doubles of course). Then, if it is zero, dlls are not called, and ea does not start (if you check that in OnInit()), if it is non-zero value, dll works. A simple script changing this GV can be written and hot keys assigned. In that case, hotkey blocks everything, and allows dll again when needed.
In case you need any help with that - I will edit my code and provide some basic examples.

How to convert string to Expression ? Using string in text file as formulas for different game variables

I'm using Unity with C#. Creating a resource management game.
I need an Index system. ie. Food Happiness index, Food Variety idex.
Each index would have different formulas.
I don't want to hardcode each indexes.
I'm looking for parsing solutions that would allow me to store the formulas as string in JSON. And evaluate these formulas during runtime.
foodhapiness = (resourceDic["food"].Production/esourceDic["food"].Consumption) * foodVariety;
foodVariety = resourceDic["fish"].count/resourceDic["meat"].count;
Also, I'm thinking of letting user add their own indexes as well. - Create text file(json) with formulas and the game should load the text file and evaluate. Like a mod.
I tried using several Expression Evaluator solutions which would have been the solution but they appear to not be working with Unity.
FLEE : Error at compile. FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
C# Expression Evaluator : Won't compile. This one Unity says something like can't load library bundle.
In Javascript, there's an Eval() function. But someone pointed out that it's risky since this allow user to run any function also I need C# solution.
It feels like I'm coming at this in the wrong way. Anyone have a better solution for something like this ?
Used NLua. It works.
https://github.com/Mervill/Unity3D-NLua
-execute Lua script stored in a string to accessing C# Properties
Don't know about the performance though.
Leave this here if anyone google and ... keywords happen to match topic name which is unlikely.. anyway.

Try to compress Sha1 down in size, maybe a better option to make unique identifier

I have the following three pieces of information. A group name, a group type, and group ranking.
As a quick example
"Mom's cats", "Cats", "Top10"
The example is way off from what I'm doing with this, but you get the basic idea.
The group name is a large selection of possible values (like around 20k) and the group type and group ranking are smaller amounts (like 10 each)
Trying to find a better way to come up with a short unique identifier for these group of things rather than having to use a sha1 with a huge ugly URL.
Any better ideas?
Open to all language solutions, so just pinning a lot of programmers here since I can't think of a better tag to assign to this.
Thanks.
EDIT: One solution that I found elsewhere a while back stated about taking the last few characters in the SHA-1 and converting them to a decimal value. Not sure how reliable this idea is and the chance of collision.
EDIT2: Using mongoDB and storing this sha1 value in the DB along with the members to make querying easy at the moment. Trying to find an alternative solution to creating an autoincrement field in a seperate table/collection which means a lot more queries when running updating scripts.
For python mappings you could use (grouptype, groupranking, groupname) as a dictionary key or you could reduce the size of the dictionaries by splitting something like a dictionary with a key of grouptype -> groupranking -> groupname.
For generating a unique url what is wrong with grouptype.rank.name or the same with / as a seperator - you could use the valid url type functions to replace invalid chars in each with %nn format.
You could use urllib.quote('/'.join([baseurl, grouptype, groupranking, groupname]) to generate such a path or even baseurl + urllib.urlencode({'grouptype':grouptype,'groupranking':groupranking,'groupname':groupname}) - the latter will result in the typical query format of baseurl?grouptype=Whatever&....

C#: a mechanism to generate regular files

following regular files (date_time.zip) would be generated at 15-min interval in ASP.NET site with Timer.
1027_0100.zip, 1027_011*.zip, 1027_0130.zip, ...
My question is I need a mechanism to restore files which are somehow missed within 3 days, like 1026_0000.zip. What data structure/algorithm would you recommend to use to implement?
PS: I intend to use another Timer to regularly restore missing files.
Thank you!
Since the naming scheme is know and the where the files are going is know. You simply need to generate what would be the name for each potential file and then check its existence using the System.Io.file.Exists. If that call fails regenerate the file.
I'll propose a slightly different solution: rather than querying the disk repeatedly, just use Directory.GetFiles(...) and Linq against that:
string[] files_that_should_exist = YourMethodToGenerateExistingFilenames();
string[] files_in_dir = System.IO.Directory.GetFiles(output_path);
var missing_files = files_that_should_exist.Except(files_in_dir);
foreach(string file in missing_files) YourMissingFileGenerateMethod(file);

How to Display the same passed variables on the crystal report using C#

I'm really sure that the title of my question depicts what i mean.i guess that's why i can't find that much on google.I think it needs to be explained.
Basically i've manage to pass programmatically discrete values to my report successfully.
Now i wanted to make use of the A4 paper format to have 2 A3 format.that means i want to have twice the display of the report.So i naively copy what i already did to the bottom of the report.The duplicated ones are not displaying for some reason.
The only workaround i can find is to create same set of parameters with different names and pass the same values to them.But that doesn't sound good to me and there are about 12 parameters.It should just be 24 if i want to do that.How you guys solve this?
Thanks for reading.
PS: using C#
Can you right click and choose Format Field and see if the "Suppress" or "Suppress if duplicated" field is ticked?

Categories