ZTree.com  | ZEN  | About...  

 Index   Back

Use eXecute, F9 or cmd.bat   [Help!]

By: Ben Kent       
Date: Mar 13,2021 at 11:40
In Response to: [Help!] Refresh screen after return from Opening batch file (David Wall)

> The Subject says it all - I run a batch file via Open and
> when it completes I'm back at the Ztree screen -
> I then have to press F3 to refresh the screen.
> Is there a .ini option to automatically do that refresh ??.
>
> Current relevant .ini settings are: Page 1
>
> P - Root only
> Q - No
> R - Always
> S - Current
> T - Current
> U - Current
> V - No
> W - No
>
> I'm in a File window as opposed to a Directory window and I run
> batch files within that window that
> create & modify files in that window - it would be nice to actually
> be able to see the changes on return from the batch file.
>
> Thanks

David

Short:
As you need to force synchronous operation for the refresh to see the file updates, your options are
1. Switch to eXecute
2. Switch to F9 application menu
3. Create bat.bat and cmd.bat files in your ZTree configuration directory, with at least "call %1" as contents


Long:

I normally have all the automatic refreshes disabled, because of the slowness of refreshing network locations, plus it can break some of the processing I do.
So I set to your config.

Your issue is that the [O]pen command is asynchronous, and so the ZTree command returns long before the thing being ShellExecute'd returns, (the thing being ShellExecute'd might even exit after ZTree) so how could ZTree know when to do the refresh? And even if ZTree did watch for ShellExecute'd commands to complete, which I suspect is non-trivial, read the ShellExecuteExA and SHELLEXECUTEINFO documentation. The subsequent refresh could come at an inconvenient time for the user. Plus the user may have changed to a different directory and ZTree doesn't have the concept of background refreshes.
Also ZTree doesn't register for Directory Change Notifications, which would be another way to handle the requirement, but again that could interrupt the users work with unexpected refreshes, a compromise would be to have directory UI indicator in ZTree that the logging information is stale, and so needs a refresh.

To see what I mean, put a PASUE command in one of your scripts. While the script is at the pause prompt, you will be able to switch back to ZTree and carry on working.

If you switch to e[X]ecute or F9 Application menu items, which are synchronous as long as you don't use Alt-eXecute in ZTree or the Start command in the scripts, and so will give you the behaviour you want.
But doing that would change your work flow.


I had the thought of razing a ZEP to make Alt-Open synchronous, so I look at the help file
"4. Quick Command Table"
File Window, Alt-Open=Open NTW
NTW - New Task Window (Asynchronous task)
I forget the details of NTW, so I cross check
2.7 File Window Commands - Alt
Alt-Open="... except that all programs, including those launched by ext.BAT files, will be run in the asynchronous mode as separate tasks. ..."
which implies that Open'ing a file with a ext.BAT file registered will be synchronous.


So to test I created this
%AppData%\ZTreeWin\cmd.bat
-------------------
@echo off
call %1
-------------------

Note: I only use *.bat for these ZTree files and when I'm coding for command.com (DOS), I use *.cmd for cmd.exe (Windows). I know many people do not follow that rule. So I suspect you will need to make bat.bat and cmd.bat copies.

Then [O]pen'ing *.cmd files results in synchronous behaviour, and so the refresh on return sees the file changes, which is what you are trying to achieve, and no need for you change behaviour.

You might need to reference "3.14 Auxiliary Files" in the help file.


Ben

648 views      
Thread locked
 

Messages in this Thread

 
96,637 Postings in 12,231 Threads, 350 registered users, 91 users online (0 registered, 91 guests)
Index | Admin contact |   Forum Time: Mar 29, 2024 - 11:27 am UTC  |  Hits:62,403,686  (18,472 Today )
RSS Feed