I have a command line being executed in my C++ code that states:
CString sCmd = "NOTEPAD /P myfile.txt";
WinExec(sCmd, SW_HIDE);
The file prints out but at the top of each page is the text, centered, "myfile.txt", next line the beginning of my file text.
Is there a way to eliminate the file title on each page of the print out and/or at least but a blank line between the title and the beginning of the text?
Thanks
This seems like an example of an XY problem.
There is no command line option for Notepad that will change or remove the page header. Notepad will remember your configured page settings though, so you could start Notepad manually, set header and footer in Page Setup, quit, then program will print using your presets.
Or, why not just use the Windows print console tool, instead of Notepad?
WinExec("cmd.exe /c print /d:\\servername\printername filename.txt", SW_HIDE);
Related
I am creating a should-be-simple batch file that will allow me to input a class name and it will take me to the correct google classroom. However, my if statement doesn't work, even when I input the word "Social Studies". It does not take me to my classroom, and on top of that, the CMD is just closed. When I remove the If Statement line, the code works fine and the cmd just stays open after inputting a class.
set /p class="Enter Class: "
IF "%class%" /I EQU "Social Studies" (START https://classroom.google.com)
cmd /k
IF /I "%class%" EQU "Social Studies"...
The parsing logic for an if statement is very specific; if [/i][NOT] arg1 op arg2 where /i and not are optional, but must if used, be used in that order.
Your code sees /i where it expects a comparison-operator and generates a syntax-error.
When you use the point-click-and-giggle method of executing a batch, the batch window will often close if a syntax-error is found. You should instead open a 'command prompt' and run your batch from there so that the window remains open and any error message will be displayed.
You can write #echo off whice prevents the prompt and contents of the batch file from being displayed.
I replaced the your EQ with == and now it works:
#echo off
set /p class="Enter Class: "
IF "%class%"=="Social Studies" (START https://classroom.google.com)
PAUSE
The PAUSE at the end will make the CMD remain open after it's done
Sometimes there is a strange issue with terminal cursor in zsh when zeus command was terminated.
The position of cursor shifts and each line of the output in the console has extra indentation, e.g.
services GET /services(.:format) services#index
payments GET /payments(.:format) payments#index
orders_verify POST /orders_verify(.:format) orders_verify#index
orders GET /orders(.:format) orders#index
diets GET /diets(.:format) diets#index
The only way to fix that is to open a new terminal window/tab
Staircasing is unrelated to locale. Full-screen programs manipulate the terminal-mode settings to let them read single characters from the screen as well as send special characters (such as carriage return and line-feed) to the screen without having the terminal driver "translate" them.
The quick fix — run this command:
reset
(you may have to press controlJ after typing "reset" to enter this properly)
Further reading:
tset, reset - terminal initialization
Make sure you have set LOCALE environment vars to UTF-8 in your .zshrc file
Open .zshrc
vim ~/.zshrc
Add these lines
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Close the file (Shift-ZZ) and reload it in the current session (or open a new terminal window/tab)
. ~/.zshrc
I am very new to C++. I have my code and it displays my desired output in a win32 console.
However, my Instructor wants the output to be run through a .txt file. We have done this before with a program that had input already written within the coding.
ex.
cout << "example1....example2";
We achieved this with his exact instructions:
*1) Probably the easiest way to obtain a hard copy of the generated
program output on a Microsoft Windows platform is to run your
program from a command prompt, redirecting the output to a file.
The command line syntax would like like this:
lab1prog >lab1.txt*
My problem, however, is that I did this again for lab2 and redirected the output to lab2.txt but I need user input for this time around. When I run the lab2.exe file, my lab2.txt file outputs my "cout" statement and waits for input but I cannot enter input through a .txt file.
Please help if you can.
When you redirect the output of the program with
lab1prog >lab1.txt
then the user is still able to input data. The only problem is that she doesn't know when to enter what data. This is usually done by prompt outputs that are hidden whith the >lab1.txt.
To circumvent the problem you could abuse the error output what is not redirected with the command above.
cerr << "prompt";
To avoid this abuse you should use a "tee" program like wintee instead of redirecting with a simple >lab1.txt.
If it's acceptable to get the input from a file instead from the user you can use the input redirection.
labprog1 <input.txt >lab1.txt
If you specifically want to use a text file as input into your program, the easiest way (as Kamil Mikolajczyk mentioned) is to run it this way:
> lab1prog >lab1.txt <input.txt
On the other hand, if you need to run the program as it is, but have complete control over what to output into the file, I'd suggest using a file handle. Check out this question on how to use file handles. You could even duplicate the output on the command prompt and the file when you want by outputting it as:
fout << "My output";
cout << "My output";
You can as well output the user input into your output file for your convenience.
I need something similar to ctrl+enter in total commander, copy current selected folder name in the panel to the command line
In some terminals (default configuration of Windows Terminal) you cannot use:
Alt+something combinations
modifier+Enter combinations
For such cases there are these sequences:
Esc, Enter or Ctrl+x, (Ctrl+)t --- copy the file (dir) name from the cursor to the command line
Esc, a or Ctrl+x, (Ctrl+)p --- copy the panel's directory path to the command line
Try the shortcut:
Left Alt + Enter
The following combination does this: Alt+Shift+Enter
How can I save all the input(cin) and output(cout, cerr) from a program whose input is taken from file(using "<")? I would like the input and output to be in order(so each input is followed by corresponding output as if I were typing the input in myself).
I tried ">" to output everything to a file, but that only saves standard output(no input/cerr), and just plainly copying the command line output still only gives the output without the input(because of how "<" works).
Is there a way to write everything(output+input) to file in order?
EDIT: edited for clarity
EDIT2: I just realized that it's impossible to do what I'm trying to do since the console does not know anything about when the commands would actually be entered. I'll have to manually enter commands and use the "script" command to actually log all input/output.
You need to add cerr to the stream
command > file 2&>1
This means put 2 (stderr) to 1 (stdout) as well.