MC 64 to execute a shell command  [SOLVED]

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1283
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

MC 64 to execute a shell command

Postby arjfca » 19 Sep 2017

Hello

This is an unresolved problem. How can I use a shell command with MC 64. The indicator use to work with MC32. Now it cause an error to my indicator.

Function to open a text file from the Name string it received

Martin

Code: Select all

//OpenNotesFile will open a text file to write notes

Input: FileName (stringsimple);
var:

intrabarpersist Path_and_FileName ("");

Once Path_And_Filename = ("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\" + FileName + ".txt");

//print (Path_and_FileName);
//File_Name = "G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\EUR.JPY_Chart_3.txt";

iF ELC.PathExists(Path_and_FileName) then begin
//iF ELC.PathExists(FileName) then begin
Print("test Exist Filename " + Path_and_FileName);

shellexecute("open",path_and_FileName);
end
else begin
Print("test Filename " + Path_and_FileName);
FileAppend(Path_and_FileName,"Note for: " + filename + NEWLINE +">" + NEWLINE + ">");

shellexecute("open",text(path_and_FileName));
end;

User avatar
rrams
Posts: 55
Joined: 10 Feb 2011
Location: Arizona
Has thanked: 4 times
Been thanked: 27 times
Contact:

Re: MC 64 to execute a shell command

Postby rrams » 20 Sep 2017

I see you have been asking about this several times in the past. I don't understand the problem.

You do NOT need to first invoke a shellexecute "open" command in order to use the MultiCharts FileAppend function to write to a file.

Code: Select all

inputs: FileName("testfile");
vars: Path_and_FileName("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\"+FileName+".txt");
once FileAppend(Path_and_FileName, "Note for: "+FileName+NEWLINE+">"+NEWLINE+">");
So what exactly are you trying to do?

If you need to constantly write to a file and MC is taking too long then you could try using the custom DLL from here:
https://fx1.net/blog/TS-slow-fileappend/
I don't know if it's a 32 or 64 bit DLL. I haven't tried it yet, because I haven't run into an issue with FileAppend.

arjfca
Posts: 1283
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

Re: MC 64 to execute a shell command  [SOLVED]

Postby arjfca » 20 Sep 2017

Hello rrams
Thanks for the reply. This problem is more on how to use the shell command from MC than to write to a file. I want to be able to start a .exe file like I use to.

I search on Google. Is it possible that the problem reside in the Shell32.dll from the ShellExecute fonction? Probably not the same in the 32 or 64 version.

Code: Select all

DEFINEDLLFUNC: "shell32.dll", int, "ShellExecuteA",
lpstr, // HWND
LPSTR, // lpOperation,
LPSTR, // lpFile,
LPSTR, // lpParameters,
LPSTR, // lpDirectory,
INT // nShowCmd
Martin

N.B.
The link provided is not operational.
https://fx1.net/blog/TS/

User avatar
ABC
Posts: 631
Joined: 16 Dec 2006
Has thanked: 119 times
Been thanked: 355 times
Contact:

Re: MC 64 to execute a shell command

Postby ABC » 20 Sep 2017

Martin,

in case the DLL is a 32bit DLL, calling it with MC 64bit will not work. That's a guess though as it's hard to tell without knowing what "cause an error to my indicator" exactly means.

Regards,

ABC

arjfca
Posts: 1283
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

Re: MC 64 to execute a shell command

Postby arjfca » 20 Sep 2017

Martin,

in case the DLL is a 32bit DLL, calling it with MC 64bit will not work. That's a guess though as it's hard to tell without knowing what "cause an error to my indicator" exactly means.

Regards,

ABC
Hello

I just realized that the MC indicator "She Example" do properly work.
So I suppose the calling .exe file from MC i supposed to work.
I will re look at my code.

She Exemple to start the Windows Calculator

Code: Select all

// run windows calculator for example
once ShellExecute("open", "calc.exe");
Martin

User avatar
ABC
Posts: 631
Joined: 16 Dec 2006
Has thanked: 119 times
Been thanked: 355 times
Contact:

Re: MC 64 to execute a shell command

Postby ABC » 20 Sep 2017

Martin,

for the shell32.dll there is in fact a 64bit version in case you are running a 64bit OS, so the function should not be the problem here.

Regards,

ABC


Return to “MultiCharts”