ShellExcecute: Any reason why the file does not open?

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

ShellExcecute: Any reason why the file does not open?

Postby arjfca » 31 Dec 2015

Hello

Working with a simple function to open a file. It does not seem to work. I did try to replace the Target file to "G:\Testfile.txt" and same result. No file is opened

Any idea?

Martin

Code: Select all

//this indicator will use a text file to take notes

Input:Pair_And_Scale (stringsimple);

once ShellExecute("open", "G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\" + Pair_and_Scale + ".txt");

once print ("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\" + Pair_and_Scale + ".txt");

Open_Notes_File = True;
The once print do return:
G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\EURJPY_1_Hrs.txt

If I copy this path to my Windows Execute, it do open the specified file

Martin

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: ShellExcecute: Any reason why the file does not open?

Postby evdl » 01 Jan 2016

Martin,

The path you use for opening the file is wrong I think. You can not use the same method for file writing to open files.

Try this:

once ShellExecute("open",
"G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\Pair_and_Scale.txt");

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: ShellExcecute: Any reason why the file does not open?

Postby JoshM » 02 Jan 2016

Following on what Evdl says, if you want to keep using the `Pair_and_Scale`variable, use the Text() keyword to concatenate the string, like this:

Code: Select all

once ShellExecute("open", Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: ShellExcecute: Any reason why the file does not open?

Postby arjfca » 02 Jan 2016

Following on what Evdl says, if you want to keep using the `Pair_and_Scale`variable, use the Text() keyword to concatenate the string, like this:

Code: Select all

once ShellExecute("open", Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));
Hello JoshM

No luck yet, the function does not open the text file. I copied your code. There is no compilation error. The function is executed, but the file is not opened

My Windows 64 is a French version. Could it be the problem????

Martin

Code from main indicator, When a Text "Button 1" is mouse clicked, the function Open_Note_File is called. See the snap picture

Code: Select all

If activeButton = Button_1_Val then Boolean_Val = Open_Notes_File (text(Pair_And_Scale));
Function Open_Notes_File

Code: Select all

//this indicator will open a text file to take notes

Input:Pair_And_Scale (string);

once ShellExecute("open", Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));

print( Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));
button 1.png
(79.12 KiB) Downloaded 1122 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: ShellExcecute: Any reason why the file does not open?

Postby JoshM » 02 Jan 2016

No luck yet, the function does not open the text file. I copied your code. There is no compilation error. The function is executed, but the file is not opened

My Windows 64 is a French version. Could it be the problem?
This seems to suggest that it's caused by the ShellExecute function, and not how it's called. I don't know much about this function (just imported it following this thread).

But perhaps you can try to use ShellExecute with the "edit" command? According to its MSDN documentation, that would "Launches an editor and opens the document for editing.". And that's what you'd like to do, right?

So the statement then becomes:

Code: Select all

once ShellExecute("edit", Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: ShellExcecute: Any reason why the file does not open?

Postby arjfca » 02 Jan 2016

No luck yet, the function does not open the text file. I copied your code. There is no compilation error. The function is executed, but the file is not opened

My Windows 64 is a French version. Could it be the problem?
This seems to suggest that it's caused by the ShellExecute function, and not how it's called. I don't know much about this function (just imported it following this thread).

But perhaps you can try to use ShellExecute with the "edit" command? According to its MSDN documentation, that would "Launches an editor and opens the document for editing.". And that's what you'd like to do, right?

So the statement then becomes:

Code: Select all

once ShellExecute("edit", Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));
Just came back, No luck with "edit" too.. I will try to see with MC team next week.

Thank you very much for your help

Martin

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: ShellExcecute: Any reason why the file does not open?

Postby arjfca » 04 Jan 2016

No luck yet, the function does not open the text file. I copied your code. There is no compilation error. The function is executed, but the file is not opened

My Windows 64 is a French version. Could it be the problem?
This seems to suggest that it's caused by the ShellExecute function, and not how it's called. I don't know much about this function (just imported it following this thread).

But perhaps you can try to use ShellExecute with the "edit" command? According to its MSDN documentation, that would "Launches an editor and opens the document for editing.". And that's what you'd like to do, right?

So the statement then becomes:

Code: Select all

once ShellExecute("edit", Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));
MC team or anyone who has the knowledge

Any idea or suggestion on why the code line given by JoshM won't open the text file on my PC (Win 10 64 bit) MC 64.

Is there a way to test "ShellExecuteA" outside of MC.

The goal is to be able to have a function to open a text file. The entry of the function is the name of the file to be open. I did try with "Open" & "edit". Same result. The function is executed but the file is not opened

Any help appreciated
Happy New-Year to all MC members

Martin

Code: Select all

//this function will open a text file. The Input string is the file name to be open.

Input:Pair_And_Scale (string);
once print ("In function: ", Pair_And_Scale);

once ShellExecute("edit", Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));

print( Text("G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\", Pair_and_Scale, ".txt"));

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: ShellExcecute: Any reason why the file does not open?

Postby evdl » 04 Jan 2016

Maybe you already tried this, but can you open the mentioned file when you

copy/paste the whole textstring:

Code: Select all

G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\Pair_and_Scale.txt
In "run" of the startmenu of windows and press enter. This will tell you if the path and file associations are right.

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: ShellExcecute: Any reason why the file does not open?

Postby arjfca » 04 Jan 2016

Maybe you already tried this, but can you open the mentioned file when you

copy/paste the whole textstring:

Code: Select all

G:\Users\Utilisateur\Documents\Bourse\Text_On_Chart\Notes\Pair_and_Scale.txt
In "run" of the startmenu of windows and press enter. This will tell you if the path and file associations are right.
Good day evdl
This was one of the first test that I initially did when the code failed to open the file. Yes the path is OK

Thanks for your input
Martin

Martin

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: ShellExcecute: Any reason why the file does not open?

Postby Henry MultiСharts » 12 Jan 2016

Hello Martin,

If you want us to study this case please send me the dll you are using, the study that utilizes the dll, the workspace and data for replicating the issue on our end to support@multicharts.com


Return to “MultiCharts”