pass argoments from double click explorer for edit .m files

47 views
Skip to first unread message

Stefano1972

unread,
May 28, 2014, 4:18:58 PM5/28/14
to fre...@googlegroups.com
Good day,

Can not create a file type for explorer to launch the file editor. M 

Once i have made ​​the explorer double click link for file type .m, FreeMat will start and execute the .m file.

I would like to edit .m file instead.

Best regards

Stefano

Jonathan Weaver

unread,
May 29, 2014, 5:03:49 PM5/29/14
to fre...@googlegroups.com
I don't know if FreeMat will take a command line argument to edit the file, but here's a workaround using the startup script functionality of FreeMat.

Create a batch file, I called it c:\freematscript\freemat.bat containing

cd "c:\freematscript\"
echo %1> startup.txt
"c:\Program Files (x86)\FreeMat\bin\FreeMat.exe"

You may need to adjust the call in the batch file to FreeMat depending on where you have it installed.

Create an m-file, I called it c:\freematscript\startup.m containing

a = fopen('startup.txt');

b = fgetline(a);

b = b(2:length(b)-3);

fclose(a);

a = fopen('tocall.m', 'w');

fprintf(a,'edit %s',b);

fclose(a);

tocall;


Then associate the m files with the batch file using Windows Explorer, and you're good to go.


There is probably an easier way...


Jonathan

Stefano1972

unread,
May 30, 2014, 4:57:30 AM5/30/14
to fre...@googlegroups.com
Thank you very much for the prompt anwer,

i get the file startup.txt, but in the line "b = fgetline(a);" of the startum.m i get the error:

In docli(builtin) at line 2
    In base(base)
    In base()
    In global()
Error: Invalid handle!


and what is tocall.m ?

Best regards

Stefano

Jonathan Weaver

unread,
Jun 11, 2014, 11:20:13 AM6/11/14
to fre...@googlegroups.com
Maybe FreeMat isn't opening the file?

tocall.m is a m-file that is called, which startup.m creates using startup.txt.  tocall.m is a simple one line command "edit whateverYouPut.m".

If it's not working and you don't want to mess with the little hack here, may I suggest using Notepad++ as an m-file editor?
Reply all
Reply to author
Forward
0 new messages