Can I export an project with the command line to a XPO file? (AX 2009) - dynamics-ax-2009

Is it possible to export an project with the command line to a XPO file? (AX 2009)

Look at the classes C\SysStartupCmd*. I know there are some funky command line tools you can use, but the easiest thing I would think is to create your own class that "does" what you want, than extend the SysStartupCmd class.
A VERY good example is Classes\SysStartupCmdCompileAll. You only need one method, and it accepts a parameter, and you add your case in the C\SysStartupCmd\construct method.
Then to call it, you call the client from the command line like, "ax32.exe -startupcmd=compileall_+" where the "+" is your parameter, if you choose to have one. "compileall" is what is referenced in the construct of the SysStartupCmd, and then you create your class with one method to do what you would like.

Related

How to test my dll file written in fortran?

I have written a Fortran code for being compiled as a '*.DLL' file.
The program which reads that file is a Finite Elements Method software named Plaxis, I already achieved to generate the '*.DLL' file in Visual Studio and Plaxis recognizes my model but the model does not work fine.
I would like to evaluate all the variables involved in my code and the procedure that Plaxis is using to read them, but when I use commands like "write(*,*) 'variable'" Plaxis does not show me what I asked in the source code.
Probably you want to open a file and write to that for debug logging, because presumably Plaxis doesn't run with standard output connected to anything useful. Or maybe it would if you just ran Plaxis from a command line window?
It's not going to create a dialog box for you.
But anyway, another option would might be attach to Plaxis with a debugger, and set a breakpoint in a function in your DLL. Then you can single-step your code as called by Plaxis.
Or you can write your own test callers and write unit tests for your functions, making them easy to debug. This could work well if your function just gets an array + size as args.
If instead it passes some wrapped object that you need to call special functions to deal with, then maybe make another version of your function that does just take an array so you can call it from a simple test caller.

what is the use of erlang compile options: "-compile({parse_transform, ms_transform})".?

As the title, does anybody could explain the use of parse_transform with ms_transform?
what the different between with it and without it ?
The -compile({parse_transform, ms_transform}). syntax invokes a parse transform.
A parse transform is a module which the compiler calls after the file or input has been parsed. The module is called with the full abstract syntax of the whole module and must return a new abstract for a whole module. The parse transform is allowed to do whatever it wants as long as the result is legal erlang syntax. It is like a super macro facility which works on the whole module not just single function calls. The resulting module is then compiled. You can have many parse transforms.
Parse transforms are typically used to do compile-time evaluation and code transformations. The ets:fun2ms call mentioned by #P_A is a typical example of this as it takes a fun and at compile-time transforms this into a match specification, see Matchspecs and ets:fun2ms. But parse transforms allow you to do much more, for example add and remove functions. An example of this is a parse transform which generates access functions for all the fields in a record.
It is a very powerful tool, but unfortunately easy to get wrong and so create a real mess. There are, however, some 3rd party support tools which can be very helpful.
ms_transform module implements parse_transform that translates fun syntax into match specifications. For example ets:fun2ms fun uses it.
Also you can use
-include_lib("stdlib/include/ms_transform.hrl").

How to programmatically inject parameters/instructions into a pre-built portable executable

I have two executables, both manually created by me, I shall call them 1.exe and 2.exe respectively. First of all, both the executables are compiled by MSVS 2010, using the Microsoft compiler. I want to type a message into 1.exe, and I want 1.exe to inject that message into 2.exe (possibly as some sort of parameter), so when I run 2.exe after 1.exe has injected the message, 2.exe will display that message.
NOTE - this is not for illicit use, both these executables were created by me.
The big thing for me is:
Where to place the message/instructions in 2.exe so they can be easily accessed by 2.exe
How will 2.exe actually FIND use these parameters (message).
I fully understand that I can't simply use C++ code as injection, it must be naked assembly which can be generated/translated by the compiler at runtime (correct me if I am wrong)
Some solutions I have been thinking of:
Create a standard function in 2.exe requiring parameters (eg displaying the messagebox), and simply inject these parameters (the message) into the function?
Make some sort of structure in 2.exe to hold the values that 1.exe will inject, if so how? Will I need to hardcode the offset at which to put these parameters into?
Note- I don't expect a spoonfeed, I want to understand this aspect of programming proficiently, I have read up the PE file format and have solid understanding of assembly (MASM assembler syntax), and am keen to learn alot more. Thank you for your time.
Very few programmers ever need to do this sort of thing. You could go your entire career without it. I last did it in about 1983.
If I remember correctly, I had 2.exe include an assembler module with something like this (I've forgotten the syntax):
.GLOBAL TARGET
TARGET DB 200h ; Reserve 512 bytes
1.exe would then open 2.exe, search the symbol table for the global symbol "TARGET", figure out where that was within the file, write the 512 bytes it wanted to, and save the file. This was for a licensing scheme.
The comment from https://stackoverflow.com/users/422797/igor-skochinsky reminded me that I did not use the symbol table on that occasion. That was a different OS. In this case, I did scan for a string.
From your description it sounds like passing a value on the command line is all you need.
The Win32 GetCommandLine() function will give you ther passed value that you can pass to MessageBox().
If it needs to be another running instance then another form of IPC like windows messages (WM_COPYDATA) will work.

Get output of shell command in Haxe

In Haxe, is there a method in the Sys class (or some other class) that returns the output of a shell command (for example, the command "ls"), or will I need to implement this method myself for each target language? I'd like to find a method for invoking shell commands that works with every Haxe target language.
Yes, your own comment contain the answer, which is:
var output = new sys.io.Process("ls", []).stdout.readAll().toString();
Or the cross platform way: sys.FileSystem.readDirectory('')
It might also be faster, because it doesn't invoke an extra process.

Visual Studio 2010: Easiest way to duplicate a class?

Is there an easy way to duplicate a class with a different name?
Not sure whether this can be qualified as the easiest way but if you have ReSharper, you can use its Copy Type refactoring to copy classes/interfaces/structs with control over the namespace the copy is landing in and naming within the copy - which means that if you're copying a class with 5 constructors, the copy will have all of them renamed to match the name of the new class.
However, depending on what you're trying to achieve, using Extract Interface or Extract Superclass might be a better option.
No, there's no refactoring tool for duplicating a class but with different name.
I would imagine that the reason why this feature is not present is because duplicating code is generally considered a bad idea. I'd suggest instead changing your class into a base class and then make two derived classes from it, overriding methods where you need to change the behaviour.
Refactor to give a new name, copy, undo, paste :-) Remember the undo! This will rename the constructors and finalizers!
Open file in Visual Studio.
Press Ctrl+A.
Press Ctrl+C.
Create a new file for the new class.
Press Ctrl+V in the new file.
Replace all old class names with the new one. (Ctrl+H)
First of all: now there is the option of "Copy Class" with the MS powertools for VS (marketplace)
Second: to all the critics that know better - there are legitimate cases where you want to copy a class as a starting point. I for example have a base class and from it I derive dozens of classes with different implementations, yet I do have a "reference class" derived from the base which already contains the overides, comments, etc. so I do not have to repeat the same over and over again.
This is just one of the many situation where you want to copy a class.
It's usually better to refactor your class to be reusable. Copy paste code leads to having to fix the same code in multiple places and much pain as you're breaking OO principles.

Resources