How to print Trace32 terminal view to a file? - arm

I have a script that initializes terminal and prints information in it in Trace32 terminal and I cannot edit that file. I am using term.write command to log the contents in terminal window to a file. But it does log the information that were written before executing this command.
So, I tried to Printer.file and winprint.term.view commands. Now I get this error.
terminal window with this configuration already open
What should I do to log all the contents of terminal (including contents that were already written and will be written in the terminal) to a file?

If you want to get the content from a window in TRACE32 while using the debugger interactively, click on the context menu, and choose "To Clipboard all". Then open a text editor and paste your clipboard to an empty document (Ctrl+V).
If you want to get the content of a window in TRACE32 via a PRACTICE script use the command PRinTer.FILE <FilenName> ASCIIE (as you did) and then the command WinPRT <WindowName> /ALL.
The pre-command WinPRINT creates a new window on the printer, which will not give what you want with Terminal windows. The command WinPRT however, actually sends the content of an open window to the printer (and the printer can be redirected to a file).
The tricky thing with WinPRT is to know the name of your window. The command WinPOS allows you set the name for next opening window. So I recommend to use WinPOS in the script opening your terminal window. But since you can't change that script use the command WinPAGE.List to get the names of all open windows.
E.g. In the following WinPAGE.List you can see that the window opened with TERM.VIEW has the window-name "W000".
Thus, I can get the content of my terminal window with
PRinTer.FILE "C:\temp\mywindow.txt ASCIIE
WinPRT W000 /ALL
Note, that window names are case sensitive.
The window names starting with a capital 'W' followed by three decimal digits are set by TRACE32 in the order they appear. So if you want to be sure that your terminal window always gets the same name, ensure that no window is open before opening your terminal window with your script. You can close all windows with WinPAGE.RESet.
So all together you get:
WinPAGE.RESet
DO "C:\T32\user\my_script_to_open_the_terminal.cmm"
PRinTer.FILE "C:\temp\mywindow.txt ASCIIE
WinPRT W000 /ALL
If you script is only opening one terminal window and no other window, I recommend to do this:
WinPOS ,,,,,,myTerminal
DO "C:\T32\user\my_script_to_open_the_terminal.cmm"
PRinTer.FILE "C:\temp\mywindow.txt ASCIIE
WinPRT myTerminal /ALL

I am late, but figured out the answer.
&LOGFILENAME=OS.PPF()+".log" ; so, filename here is "<this_current_path_filename_with_extension>.log"
PRINT " Printing to log file: &(LOGFILENAME)"
PRinTer.FILE &LOGFILENAME ASCIIE
; select and open display the AREA you want to print to file; here it is default T32 log area A000
AREA.Select A000
AREA.View A000
WinPrint.AREA.View
;AREA.CLEAR ;if you want to clear the view for next set of prints
Alternatively, in real-time, write-to-file is
OPEN #1 OS.PPF()+".log" /CREATE ; so, filename here is "<this_current_path_filename_with_extension>.log"
;...
WRITE #1 "Hello World - it is " DATE.TIME()
;how many ever WRITE's you want in the code
;...
;...
WRITE #1 " BYE"
;...
CLOSE #1

Related

Trying to start multiple .exe files in order with a bat file but first line fails and second line is successful

My code in the .bat looks like this.
"C:\users\reshade injector.exe"
C:\pathtogame\game.exe "added argument"
"c:\users\reshade injector.exe" <- if I open the actual file, it opens a command window and waits for my other application to launch. Is this a console app?
C:\pathtogame\game.exe "added argument" <- this works and launches my game
Another issue is that when launching the first .exe, a command window stays open. How do I make the command window not appear?
Can anyone help me with these two problems?
*edit for clarity
by opening the actual file, I mean double-clicking on the original reshade injector.exe.
When opening reshade injector.exe, two cmd windows open. They close as soon as I launch the game.exe.
I can't seem to get the reshade injector.exe to launch through the .bat file.
Batch will run any application it finds. If the application does not terminate (eg. it's waiting for user-input) then it will progress to the next instruction.
Some applications work by launching another (the user-interface) and then terminating, leaving the second application resident.
There's no way to tell without observing which approach any random application may take.
So - your batch should execute a file named c:\users\reshade injector.exe.
You say that "fails". Is there an error message generated? You would likely need to run the batch from the "command prompt" to see that message. Note that the Space between reshade and injector must be in the actual filename. If injector.exe is a file in a subdirectory called reshade, then you need a backslash between reshade and injector.
Having resolved the actual name of the first executable, try
#echo off
setlocal
start "" "firstexecutablename"
start "" "secondexecutablename" "arguments"
The first two lines prevent "command echoing" which is used for debugging and establish a "local environment" which ensures the "environment" for the batch file remains unchanged when the batch terminates. In the current case, these two lines are probably unnecessary, but it's SOP for batch files.
The batch should then close its session and window once it has attempted to launch the two applications.
The "" following start becomes the window-title. It can be any quoted string you like, but should not be omitted as start uses the first quoted string it finds as a window-title and may not recognise it as part of the executable/arguments.

Cannot send arguments to batch file converted to application via IExpress

I have made a batch file which contains personal data, so to hide it from other people and to post it, I decided to "encrypt" it converting it to exe via IExpress.
My batch file is named prime.bat and it is located in %userprofile%.
Here are the steps I ran with iexpress.exe:
Runned iexpress.exe.
Selected Create new Self Extraction Directive file
Selected Extract files and run an installation command.
Entered package title (Prime finder).
Selected No prompt..
Selected Do not display a license..
Selected prime.bat located in %userprofile% (C:\Users\%username%).
Entered cmd /c prime.bat in Install Program and left Post Install Command as is (<None>).
Selected Default (recommended).
Selected No message.
Entered C:\Users\username\prime.exe and did not check any of boxes below.
Selected No restart.
Selected to save SED file.
Package created successfully!
As the batch file works with arguments, it must be run from the cmd. When I clicked the file single from explorer it opened correctly. Because I had put an error message if there are no arguments, it threw expected error and exited with 1. If I type just prime.exe in cmd, the above happens, and same output is produced.
But, if I run file from cmd again, but specify arguments, I get an error message in a new window. As I don't use English language and do not have the permissions to change language, I will try to translate the output:
Syntax error appeared in command line's selections.
Type /? after the command for help.
So, I typed prime.exe /?, and a new window with help appeared. I think I am missing something in iexpress.exe options.
I solved my problem using:
prime.exe /c:"cmd /c prime.bat numeric_arguments"
Which should be used when you want to send arguments to an IExpress 'compiled' file as /c option specifies a new install command.

run wordpad print and delete tempfile in progress 4gl?

I have a rtf file with data and now I have created a temp file and batch file . Now how do I run wordpad print and delete tempfile in progress 4gl
you can use the write.exe command line options:
write.exe /pt someFile.rtf "Microsoft XPS Document Writer"
Here the "Microsoft XPS Document Writer" printer is used. You can list available printers with powershell "get-WmiObject -class Win32_printer | ft name, systemName, shareName"
You use the OS-COMMAND method. You can do that to invoke any os-command in any supported OS.
OS-COMMAND [option] VALUE("whatever command you like to run").
There are three different options
SILENT
After processing an operating system command, the AVM shell pauses. To exit the window in Windows GUI platforms, you must type exit. To exit the window in Windows character platforms, you must type exit and press RETURN or SPACEBAR. You can use the SILENT option to eliminate this pause. Use this option only if you are sure that the program, command, or batch file does not generate any output to the screen. Cannot be used with NO-WAIT.
NO-WAIT In a multi-tasking environment, causes the AVM to immediately pass control back to next statement after the OS-COMMAND without waiting for the operating system command to terminate. Cannot be used with SILENT. This option is supported in Windows only.
NO-CONSOLE While processing an operating system command, the AVM creates a console window. The console window may not be cleaned up after the command is executed. You can use the NO-CONSOLE option to prevent this window from being created in the first place.

Need a script to copy text from the script file to my clipboard

Alright so I play a game called league of legends, and when you start a game you can search for you champion, you can search for multiple champions at the same time by separating their name by this "|". So I have made different lines of champions I play for each role, right now I have to manually copy/paste the text into the search bar. I would rather just double click a script file on my desktop and have it automatically copy the text to my clipboard.
#echo Jack^^^|John^^^|Tom|clip
echo is the command to print something.
# supresses command repetition
| is a command of it's own (called "pipe" - it gives the output of the command before to the command behind)
^^^| tells the script to NOT execute the pipe symbol, but to print it as a char
All in all, this puts "Jack|John|Tom" into the clipboard.

how to open unregistered file in not installed program via batch?

Firstly, I've seen this.
Now, I would like to open a file which has unregistered extension in the program which is not installed in windows, all via batch.
START "%~dp0\arch\file.nesta" "%~dp0\Virtua.exe"
rem this will open only program
pause
START "" "%~dp0\arch\file.nesta" "%~dp0\Virtua.exe"
rem and this will summon "Open in program" win window
Point is to drop a file into program with one (double) click.
(exe file and bat file ar in same folder while file is in "arch" subfolder)
Syntax for command START
Squashman has given already the (nearly) right answer which I explain here in more details.
Running in a command prompt window start /? displays help for this command also described by Microsoft on page about command start with entire command line reference in menu on left side.
After command START there should be specified the "title for command window" in double quotes. This can be also an empty string specified with "" if the application to start is a GUI application and not a command or console application. The title of the GUI window is always defined by the GUI application and not by command processor. So a meaningful title string instead of an empty title string makes sense only for console applications and commands of Windows command processor executed in a new console window.
A title string in double quotes is not necessary if there is no string on entire line enclosed in double quotes because no parameter string contains a space or a character from this list: &()[]{}^=;!'+,`~ This character list is displayed at end of last output help page on running in a command prompt window cmd /?
Then one or more of the optional parameters of START itself must be specified on the line if one of those parameters is required for the task at all.
The next parameter must be the command or application to run as new process. START can be also used to just start a new command process with a new console window and therefore a command or application must not be specified. But START is used in in batch file usually to run an application in a separate process and not for just opening a new command prompt window.
And last are specified the parameters of the command or application to start.
What does this mean in practice?
Command START with one parameter in quotes
START "%~dp0\arch\file.nesta"
Command START creates in this case a new command process with Drive and path of batch file\arch\file.nesta as title for the new console window displayed in title bar of the window. So the single string in double quotes is interpreted by command START always as title string for a new command window.
Command START with two parameters in quotes in wrong order
START "%~dp0\arch\file.nesta" "%~dp0\Virtua.exe"
This results in starting Virtua.exe in directory of batch file with Drive and path of batch file\arch\file.nesta as title for the new console window in case of Virtua.exe is a console application.
But even if Virtua.exe is a GUI application, the string %~dp0\arch\file.nesta is already taken by command START as window title not being displayed anywhere and therefore Virtua.exe is always started with no parameter using this command line.
Command START with two parameters in quotes in right order with missing required title string
START "%~dp0\Virtua.exe" "%~dp0\arch\file.nesta"
This results (most likely) in an error message as Drive and path of batch file\Virtua.exe is interpreted as title and command processor can't find in directory Drive and path of batch file\arch a file with name file.nesta.* with a file extension listed in environment variable PATHEXT.
Command START with two parameters in quotes in right order and with required title string
START "" %~dp0Virtua.exe" "%~dp0arch\file.nesta"
This is the right command to start Virtua.exe in directory of batch file with file.nesta in subfolder arch of batch file folder as parameter for Virtua.exe and given the console window no title if Virtua.exe is a console application.
There is no backslash after %~dp0 as this string is expanded by command processor always to drive and path of batch file ending already with a backslash before command START processes the parameters.
Using %~dp0\ would result in \\ between path of batch file folder and for example Virtua.exe which is not 100% correct. However, Windows automatically cleans up file and folder strings with \\ inside and therefore this small mistake would have no effect on execution.
Summary
On specifying ALWAYS first a title string in double quotes after START makes your batch coding life easier.
Using "" for a GUI application and "Something meaningful" for a command or console application as title string makes it easier for the users of the batch file to identify what the opened console window is for in list of running applications displayed on using Alt+Tab, in Windows task bar depending on the used task bar options (just symbol displayed or symbol with begin of window title) and in Task Manager of Windows.
Note:
There are combinations of not quoted parameters and quoted parameters which do not require a quoted title string. But it is really much easier to specify always a title string instead of finding out when a title string in quotes must be specified and when it is possible to omit it if any parameter is enclosed in quotes.

Resources