Page 1 of 1
Via Tool button I would like to Change File Open Directory
Posted: Thu Jun 28, 2007 1:40 am
by Ed Grossheim
6/27/2007 8:33:02 PM
I haven't given up yet..... but I would accept charity-help as I would like to change the File Open Directory, at the click of a tool button.
In Microsoft Word, I do this in VbScript with a command called ChangeFileOpenDirectory.
This is critcial as I will work in folders far removed from eachother.
When I click on Open File I would like to open the exact folder I want (After I clicked the button which would make this happen).
Any clues?
Thanks, Ed

Posted: Thu Jun 28, 2007 2:49 am
by jussij
Hi Ed,
I would like to change the File Open Directory, at the click of a tool button.
In the Zeus
zScript directory there is the
file_open.lua macro script which will display the file open dialog using the directory of the current file (i.e. the directory is configurable).
You should be able to use a similar macro code to achieve the result you are after
When I click on Open File I would like to open the exact folder I want (After I clicked the button which would make this happen).
Rather than making this a two step process I would suggest making it a single step where by you just bind your
file_open macro directly to the toolbar button.
If you use the
Options, Toolbar Options menu you will see several
Run this macro script buttons. Just add the first few of these to the toolbar.
The only tricky part is to remember these button line up with same order as the
Macros menu and because this menu is document type dependent, the toolbar buttons can change depending on the file (i.e. document type) being edited.
So to work around this you need to make sure you add the changes to the default document type. For example after adding the first macro button to the toolbar you will notice the first button runs the
Welcome to Zeus macro item which is also shown as the first item of the
Macros menu.
So all you need do edit the
default document type and change this macro to now run your special file_open macro.
Because you are changing the default document type, this means the buttons will be effectively constant for all other document types
Cheers Jussi
PS: FWIW the Alt+Shift+E is bound to
FileOpenEx function which will display the file open dialog using the directory of the currently active document. You might also want to bind this function to some other key.
While I continueon with the help of your ans. - More details
Posted: Thu Jun 28, 2007 3:27 pm
by Ed Grossheim
6/28/2007 9:49:24 AM
I am trying to work with your answer... In the mean time I am sending a couple further details about where I am trying to go.
I am trying to understand the nature of the Default Directory of the Current Document.
e.g. I have three files open, each in different folders.
If I go to any tab, making that file my current document, and then (as if I want to Open a fourth file )
Using the menu I click on File Open, for File Open, Zeus pulls a file open dialog on the chronologically last folder (file) I imported.
So for File Open, Zeus thinks this is the "Default Folder".
Now if I go to any tab, making that file my current document, and then (as if I want to Save the file)
Using the menu I click on File Save, Zeus knows the Default Folder is the folder This File came from.
So a Zeus "File Open Dialog", Zeus thinks either of two folders is the Zeus default and opens that folder in the File Open Dialog.
Which folder opens depends on whether I am saving a file, or Opening a file..
===========================================================================================
My situation is that I will be operating in say 5 widely separated folders. I will want to quickly open any one of them. I will want to
quickly Save the Current document to any one of my five folders (each may even be on a different drive).
So when I do either the menu File Open, or File Save (or Save As) .... I want to immediately see the Open File Dialog on the folder I desire, without indexing through many levels and drives to adjust the Dialog Box to be on the desired folder. I want one macro that once run makes all of this so.
In Microsoft Word (2002), my macro uses the FileOpenDirectory command, when I run this macro on a button ..... no matter how many documents I have open in Word, no matter which document I am currently on:
If I chose File Open, or File Save (or Save as) .... the File Dialog box that opens is right there "on my desired folder".
In Word, this is my macro:
Public Sub CHOOSEDIR4()
' PROCEDURE WRITTEN 6/29/04 by ED GROSSHEIM
ChangeFileOpenDirectory _
"C:\Documents and Settings\Ed\Application Data\Microsoft\Templates\"
End Sub
I have added a Custom Toolbar with five buttons bound to five macros similar to the one above.
==============================================================================================
Will get back, Ed
I think I am out of ideas !
Posted: Thu Jun 28, 2007 8:23 pm
by Ed Grossheim
6/28/2007 3:20:03 PM
Sorry,
I am afraid I need another clue. I tried.

- Ed
Posted: Thu Jun 28, 2007 11:14 pm
by jussij
Hi Ed,
Currently Zeus does not have a way to set the file open default directory.
The Zeus
FileOpen function default directory is always the last used directory.
The Zeus
FileSaveAs function will always save to the directory of the currently active file and if no file is active it then uses the default directory.
The
FileOpenEx function can be used to indirectly change the default directory.
For example if you use the
Macros, Execute Scripts menu:
and type in
FileOpen - you get the last used directory.
and type in
FileOpenEx - you will get the directory of the currently active file.
If you edit the
file_open.lua macro script and change this line of code:
Code: Select all
-- the starting directory
--local dir = macro_tag("$FDD")
-- use this as the file open directory
local dir = "c:\my\directory"
and then use the
Macros, Execute Scripts menu and type in
file_open.lua the file open dialog will open in the
c:\my\directory.
You can bind this macro to the toolbar as described earlier.
Cheers Jussi
Final Thought
Posted: Fri Jun 29, 2007 3:31 am
by Ed Grossheim
6/28/2007 9:53:51 PM
Hi Jussi
Well call me crude, but I have a work-around that is sufficient for me.
e.g. I want to change the directory to "text notes temp".
In this desired directory I placed an empty file "x.vbs"
I set a tool up under Tools/Options/Default doc type/Tools
Calling the Tool "Pick Dir Text Notes Temp"
Dos Command, Run hidden.
Arguments: zeus "C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\x.vbs"
I run the tool, I choose the x.vbs tab click on File Save As and save it (choosing replace it if it asks).
Then File Open or File Save/or As buttons show me my Text Notes Temp Dir.
Not pretty, but good enough.
Part of my confusion is that I cannot find sufficient examples of functions being scripted to understand what I am doing.
The examples that are there are mostly in lua, and I am not very interested in grasping the idiosyncrasies of lua.
e.g. Knowing vbscript fairly well, I still can't even figure out how to use the "fileopen function" that you say is scriptable in vbs.
I would like to be able to look at ten example vbs scripts that each refered to a different scriptable function (five that referred to built in Editor functions and five that referred to Keyboard functions).
In Zeus Help, under functions it says:
"The functions listed below are built-in to the Zeus editor itself and can be used by all of the supported scripting languages. In addition to these built in functions it is also possible to script any of the Zeus
keyboard functions. "
For Zeus to be super useful to the user ....he Must understand how to script Zeus using his favorite script language. It is not enough for the user to know his favorite language, he needs to see a variety of
code block examples that paint the picture.
I learn from looking at examples (small and specific) that work if I execute them.
I would be glad to submit examples in vbs, if I could get smart enough to write test code and prove the snippets work!
If I could understand the methods of the Zeus object better, so that I could easily script all functions that are scriptable I could find better workarounds.
Thanks for your Help - Ed
Posted: Fri Jun 29, 2007 4:34 am
by jussij
Hi Ed,
Arguments: zeus "C:\Documents and Settings\ED\Desktop\TEXT NOTES TEMP\x.vbs"
I can see how that will work
e.g. Knowing vbscript fairly well, I still can't even figure out how to use the "fileopen function" that you say is scriptable in vbs.
Here is an example in vbs:
Code: Select all
Function key_macro()
'set the starting directory
directory = "d:\temp"
'build a file filter string
cpp_files = "C/C++ files (*.cpp;*.c;*.hpp;*.h)|*.cpp;*.c;*.hpp;*.h|"
res_files = "RC files (*.rc;*.rh;*.dlg)|*.rc;*.rh;*.dlg|"
txt_files = "Text Files (*.txt)|*.txt|"
'the two argmument version of the file open dialog
file_name = zeus.file_select_dialog( directory, cpp_files & res_files & txt_files )
if Len(file_name) > 0 then
zeus.file_open(file_name)
end if
End Function
key_macro() 'run the macro
five that referred to Keyboard functions
When writing macros I always suggest letting Zeus do all the hard work
For example, assuming you have configured
VbScript to be the default scripting language, as a starting point all I would do is the following:
- Macros menu, Record Start/Stop
- File Menu, New
- Type in "This is a test macro...."
- Macros menu, Record Start/Stop
- Macros menu, View Source
What this does is create the following macro script:
Code: Select all
Function key_macro()
call zeus.screen_update_disable
call zeus.FileNew
call zeus.write("This is a test macro....")
call zeus.screen_update_enable
call zeus.screen_update
End Function
key_macro() 'run the macro
In this example Zeus has written a macro with several calls to built-in functions (i.e screen_update, screen_update_enable, write etc) and the one call to the FileNew keyboard function.
Naturally, if you use a different set of menu and/or key strokes combinations Zeus will write you a differnet macro
I would be glad to submit examples in vbs, if I could get smart enough to write test code and prove the snippets work!
The thing to remember is the built-in functions are all in lower case and are described in the built-in function section of the online help.
The camel case functions are the Zeus keyboard functions and these are listed in the
Options, Editor Options menu,
Keyboard Mapping panel, select a mapping to edit, hit the
Edit button.
Where available, you can also view the help for a keyboard function by placing the cursor on the keyboard function text and using the
Help, Quick Help Current Word menu.
If I could understand the methods of the Zeus object better
The Zeus scripting layer is different to other VbScript application interfaces in that it really does not have an object. There are just built-in functions and keyboard functions and that is it
The
zeus. qualifier is just needed by VbScript to let it know that you are calling one of the Zeus functions.
Cheers Jussi
Thanks, that helped.
Posted: Fri Jun 29, 2007 2:06 pm
by Ed Grossheim
6/29/2007 8:56:50 AM
I will be studying this, and trying stuff today (and tom !).
I've got the file open working, elegance may not be far away!
I see I can execute a script as a Tool or a Macro. Is there anything I could add to the script at the end to suppress the "Tool" tab window at the end?
I have a tool set to bring up (via .exe) a notepad file of "crib notes".
I bring it up, make notes, then exit. Then Zeus brings up the tool tab that I have to right click on and close.
Thanks for all the great points, and the patience.
-- your friend in Zeus, Ed
Posted: Sun Jul 01, 2007 1:03 am
by jussij
Hi Ed,
Is there anything I could add to the script at the end to suppress the "Tool" tab window at the end?
If you turn off the capture standard output and standard error options in the tool this should remove the Tool window.
Cheers Jussi
It worked
Posted: Mon Jul 02, 2007 5:25 pm
by Ed Grossheim
7/2/2007 12:25:30 PM
Thanks Jussi.
--Ed
Posted: Tue Aug 07, 2007 12:57 am
by jussij
The latest Zeus patch provides a way to set the working directory:
bool set_default_directory(directory)
Set the default directory. The default directory is used by the file open dialog.
The latest Zeus 3.96i patch can be found here:
http://www.zeusedit.com/forum/viewtopic.php?t=1231
Cheers Jussi
Wow !!! I just can't believe the SERIOUS Support for Zeus
Posted: Wed Aug 08, 2007 12:36 am
by Ed Grossheim
8/7/2007 7:26:34 PM
Ok I have downloaded the patch, but I will give serious attention to this in the week ahead.
I was coping fine with macros like:
Code: Select all
Function key_macro()
directory = "C:\Program Files\Zeus\zScript"
file_name = zeus.file_select_dialog(directory)
'I have no idea why these three lines are important, but without it I have trouble opening this file!
if Len(file_name) > 0 then
zeus.file_open(file_name)
end if
End Function
But I had about one dozen macros like this in my drop-down macro menu!!!
This will be a valuable addition to a terrific Script Editor.
I have been putting Zeus to some extreme use, and have been very happy with it.
Applause and Cheers

to Jussi - Ed
[/color]
Posted: Wed Aug 08, 2007 2:21 am
by jussij
Hi Ed,
I'm glad to read Zeus is working for you
Code: Select all
'I have no idea why these three lines are important, but without it I have trouble opening this file!
if Len(file_name) > 0 then
zeus.file_open(file_name)
end if
Why you need these three lines is the
file_select_dialog function only returns the name of the file as selected by the user.
But if the user hits the cancel button then a string of length zero is returned.
So these three lines basically read
if the user did not hit cancel, open the file selected by the user
Cheers Jussi