I need to generate a random character during an NSIS installer script multiple times.
Is there a pre-defined function or is it even possible?
If yes: How?
There is no predefined function but the wiki has plugins and basic (non-crypto) pure NSIS random functions to choose from:
http://nsis.sourceforge.net/Rnd
http://nsis.sourceforge.net/Random
http://nsis.sourceforge.net/Pwgen_plug-in
http://nsis.sourceforge.net/NsRandom_plug-in
http://nsis.sourceforge.net/Generate_a_random_number
Related
I have a model in Modelica language (platform: Dymola). Dymola creates a binary file of model during compiling/translation (dymosim.exe). If binary code export licence is available then a binary file which is standalone representative of original dymola model is created. This can be run on any computer without Dymola licence.
Now, My question is how can I create Gui for around this executable file with following requirements:-
1. It should be able to change in some input parameter values.
2. It should be able to get some output parameter values.
Now as background:-
dymosim.exe takes parameter values as input from text file (dsin.txt) and writes output in another text file (dsres.txt)
Specifically, if one has such binary executable which takes input from a text file and writes output in specific format (of which rules are known) to another text file; then what are some tools to create gui for it?
Look into Dymola's embedded server support (DDE/OPC). Since you are using dymosim.exe, I believe you are using Windows so Dymola's restriction on only Visual Studio 32-bit code for embedded servers will be acceptable. (Most Modelica tools have similar embedded servers, but I don't think they are compatible.)
Dymola dymosim.exe exports its time series results as *.mat files, you should be able to find tools/libraries to handle *.mat format in your GUI.
Also, dsin.txt has its own format, you can try to understand it first (try to find its comments) and then parse it, it's not a text file with random string and number columns.
To use FMI standard is worth to consider in the co-simulation mode which means that a solver is included. Dymola allows to export model as FMU package (in Windows platform it is single DLL with some metadata, in Linux platform it is .SO library) and provides these functions worth to do your steps:
fmiSetReal() will set a parameter value
fmiDoStep()
fmiGetReal() will get the variable value
You can call these functions directly, just unzip FMU package and find the DLL inside and link it directly to your application.
Or recommended way (we did it in our app): use FMI Library providing general C API interacting with a FMU package and controling temporal structures the way you need.
I am wondering what is a good way to use Python to generate an arithmetic worksheet consisting only of 2-digit numbers squared. Specifically I want to be able to call upon a Python program in which it asks me for parameters such as the range of the numbers in can call upon to square and the number of questions I want to generate. Once that is done the program will generate the numbers and then automatically open up a .tex file (already with preamble and customizations) and basically do a loop for each question like this:
\begin{exer}
n^2
\end{exer}
%%%%%Solution%%%%%%
\begin{solution}
n^2=n^2
\end{solution}
for some integer n.
Once it is done writing the .tex file then it will run xetex and output the pdf ready to use and print. Any help or suggestions? Python is preferred but not mandatory.
Actually your problem is so simple that doesn't require any special magic. However I would suggest you don't try to append your generated content into a file you already have with preamble, good practice is to leave it untouched and include (in fact you can copy it on generation or use TeX \include).
Now, let's add more to the generation. Python formatter is your friend here, you use the example you've given as a template, and write the product into a file in every iteration. Don't forget to escape "{" brackets, as they're symbols used by formatter.
At the end, (suggestion) you can subprocess to launch XeTeX - depending on your need call() is enough or use popen().
I want to read a txt file in autocad and plot them (line/polyline).
it may looks like
1 x11 y11 z11.......x14, y14,z14 % polyline 1
..
n xn1 yn1 zn1.......xn4, yn4,zn4 % polyline n
I want to know what is best and easy way to do this. What programming language I should use.
What are useful links or is there somework already done in this direction.
Best regards,
No programming language required! Just create a text file and type AutoCAD commands in the file the same way you would at the AutoCAD command prompt. Save the file with the .scr extension and you can either drag the file onto the AutoCAD window, or use the script command in AutoCAD to find and run the command script.
More info: http://www.upfrontezine.com/tailor/tailor19.htm
I actually use Python to generate these command scripts. With the power of a modern language, and throwing in some AutoLisp, you can do surprisingly sophisticated things. I've used this to model a complex steel tower for a cablestay bridge, and for testing model geometry for Larsa modeling.
There are few ways you can do it.
Simple solution
Script file
Creating a script file is easier and quicker
http://docs.autodesk.com/MAP/2010/ENU/AutoCAD%20Map%203D%202010%20User%20Documentation/HTML%20Help/files/WS1a9193826455f5ff47b7aa4b11fbe75ecf1-65dc.htm
AutoLISP automation
This is also easier and quicker plenty of online resources available.
http://www.pixelgraphicsinc.com/AutoLisp_Tutorial01.html
Best but complicated solution
.NET C# plugin
This is the best option as it lets you do more than basic things.
If you like to do coding. This is fun. you can create a plugin using .NET C# and read the txt file to create the line segments.
Let me know how you go.
You can use ObjectARX in C# as well as C++.
C# will be a better choice.
Just read your text file using StreamReader using C# System.IO library.
Create a array of points specified in text file.
Finally create the Polyline using given points and Using Transient in ObjectARX you can display the Polyline.
While in a folder with lots of files, one can select many and rename only one. This one will get the name NewName (1) and the rest will follow as NewName (2) etc..
Is there a way to use this algorithm?
I mostly interested in using WinApi methods in general. It is easy to implement this specific algorithm. I don't know how to dig into explorer.exe and see what method it uses but probably it would be something reusable.
I mostly use c# but any language example would be accepted.
Not with a single function call, no. But you can loop through the files one at a time using SHFileOperation() with the FOF_RENAMEONCOLLISION flag to rename each file to the same target filename so Windows will generate its own unique filenames.
As pointed out by Remy Lebeau I came up with the official way to do it.
IFileOperation::RenameItems
Declares a set of items that are to be given a new display name.
All items are given the same name.
...
If more than one of the items in the collection at pUnkItems is
in the same folder, the renamed files are appended with a number in
parentheses to differentiate them, for instance newfile(1).txt,
newfile(2).txt, and newfile(3).txt.
Here is the referenced link.
This also answers my question on where to start to using windows shell api to do stuff. The answer is here.
Yes it is possible see here http://blog.gadodia.net/stupid-windows-trick-mass-renaming/ I used this to oganized and Number files in mass
I have to build a GUI application on Windows Mobile, and would like it to be able user to choose the language she wants, or application to choose the language automatically. I consider using multiple dlls containing just required resources.
1) What is the preferred (default?) way to get the application choose the proper resource language automatically, without user intervention? Any samples?
2) What are my options to allow user / application control what language should it display?
3) If possible, how do I create a dll that would contain multiple language resources and then dynamically choose the language?
For #1, you can use the GetSystemDefaultLangID function to get the language identifier for the machine.
For #2, you could list languages you support and when the user selects one, write the selection into a text file or registry (is there a registry on Windows Mobile?). On startup, use the function in #1 only if there is no selection in the file or registry.
For #3, the way we do it is to have one resource DLL per language, each of which contains the same resource IDs. Once you figure out the language, load the DLL for that language and the rest just works.
Re 1: The previous GetSystemDefuaultLangID suggestion is a good one.
Re 2: You can ask as a first step in your installation. Or you can package different installers for each language.
Re 3:
In theory the DLL method mentioned above sounds great, however in practice it didn't work very well at all for me personally.
A better method is to surround all of the strings in your program with either: Localize or NoLocalize.
MessageBox(Localize("Hello"), Localize("Title"), MB_OK);
RegOpenKey(NoLocalize("\\SOFTWARE\\RegKey"), ...);
Localize is just a function that converts your english text to a the selected language. NoLocalize does nothing.
You want to surround your strings with these values though because you can build a couple of useful scripts in your scripting language of choice.
1) A script that searches for all the Localize(" prefixes and outputs a .ini file with english=otherlangauge name value pairs. If the output .ini file already contains a mapping you don't add it again. You never re-create the ini file completely, your script just adds the missing ones each time you run your script.
2) A script that searches all the strings and makes sure they are surrounded by either Localize(" or NoLocalize(". If not it tells you which strings you still need to localize.
The reason #2 is important is because you need to make sure all of your strings are actually consciously marked as needing localization or not. Otherwise it is absolutely impossible to make sure you have proper localization.
The reason for #1 instead of loading from a DLL is because it takes no work to maintain this solution and you can add new strings that need to be translated on the fly.
You ship the ini files that are output with your program. You also give these ini files to your translators so they can convert the english=otherlanguage pairs. When they send it back to you, you simply replace your checked in .ini file with the one given by your translator. Running your script as mentioned in #1 will re-add any missing translations if any were done while the translator was translating.