Crt library changes console encoding, pascal - windows

I generated a table into console and it went great but when i add "uses crt;", the labels, lines etc. which I made using chr(ord.value); , and also language special characters go wild, so I guess it somehow changes encoding.
I work in Win7,FPC IDE v.2.6.4
Another wierd thing is that when I run the program, it starts in cmd.exe classical Windows console but after like 10 seconds it closes itself and a new run is started in another console located in FPC window(where it doesn't close itself).
The wierdest thing is that the adding of "uses crt;" doesn't do anything with the table written into cmd.exe classic Windows console...
So my solution whould be either to work out how to change the encoding in the console located in FPC window or how to prevent cmd.exe from closing itself.
Hope Someone can help me, I'll really appreciate it.

If youd don't use Crt, then output is using standard DOS routines. Crt unit redirects the Input and Output standard text files to CRT instead to DOS's standard input and output files. But you can explicitly assign it back by executing:
Assign(Input, ''); Reset(Input);
Assign(Output, ''); Reset(Output);

Related

Alternative to cmd and powershell for stdout output only

My use case:
I kick-off a Python script from a button within Excel to do some data aggregation. The setup currently works nicely, but I would like:
Cmd to never accidentally pause - it's a known feature of the command prompt to pause on any text selection: Avoid pausing tasks when select something on PowerShell and Command Prompt
To let the cmd prompt look more like a pop-up
I have noticed NSIS installers outputs it's commands in a little logging box:
Question:
I would like to know if there are any programs out there that does most of what I want already. E.g. something like RunLikePopup.exe c:\path\to\script.bat, with output like:
Not sure what you are really after. I 'll give it a try.
In case you build an application as 'console'-only than that results in a 'command-line-interface [CLI]' Look-and-feel. Plane and simple. The output of a NSIS script (.nsi file) can not be paused as it is simply the output of the compiler executing the script code. 'Pausing' that would instantly mean pausing the compiler to do its work. I see no reason why you would want that.
Example Unix 'more' command (sending text oriented content to stdout. CLI...)
https://en.wikipedia.org/wiki/More_(command)
In case you need to 'catch' the output from the NSIS compiler here is what you need to do:
run NSIS from (Windows) CLI:
makensis [ option | script.nsi | - ] [...] > compiler_log.txt
What you appear to want is typically named 'output redirect'. (https://ss64.com/nt/syntax-redirection.html). In case you need to 'catch' the outpout from a NSIS script at compile time, please use NSIS ' CLI and redirect the (compilers) output to any text file (e.g. compiler_output.txt)
PS. In order to ensure receiving good quality answers, try to be as specific as you can in your questions.
I have written a Freeware editor ME "Martins Editor" where you can send text via inpipe:
[C:\]dir /s | me in
"in" always shows the first page (does not scroll), "ins" scrolls and "inp" scrolls page by page. In this context, "me in" is a substitute for "more".
Then you will see the output in the editor. ME is a simple editor with the focus on multiplatform text (different EOL encodings, codepages). It has additional Wordstar ("IDE classic") key setting and HTML/XML highlightning. It is available for Windows, OS/2, Linux and MacOS.
http://www.hypermake.com/english/betatest.html#hd117
The 2016 version is still current. In the next weeks, I publish a new version.
I am working on a cmd.exe window replacement (commandline frontend) "MeShell" based on ME with look-and-feel of a normal commandline window. Because on the lack of a modern comfortable commandline window on the old OS/2 platform which is still alive (http://www.arcanoae.com), I will publish an OS/2 version first. If this version works fine, I will publish a Windows version later. In the context of MeShell, I improve the inpipe functionality of ME which is still buggy and does not support colors in the 2016 version.

CMD Redirection not Working — .exe Opens New Window

Windows 7.
I may (or may not) have done something to the Firmware in my video card. I am trying to run nvflash, to investigate and fix the problem.
The whole scenario has been plagued by numerous appalling inadequacies, including the fact that the #BIOS installer does not tell you the name nor location of the program being installed. For all I know, nvflash is the wrong program.
I am trying (at this stage) to run "nvflash /a", to get a list of applicable (and seen) video cards.
Each time I execute the command in the CMD window, it opens a new window, displays the output there and then immediately closes the window.
I have tried using | > and >> and (after teething problems with these) I am getting no error messages, but not output in the text file.
The command I am using is as follows.
nvflash /a >> "c:\users\adminaccount\my documents\out001.txt"
I have also tried adding 2>&1 .
Any help would be greatly appreciated.
p.s. As usual, I note that I resent my [spaces added for readability] being deleted. If the commands are obscure... don't blame me.
p.p.s. I don't understand why it is not originally designed to display useable output.
(Disclaimer: I don't know anything about the internals of nvflash)
I would suspect that >> (append to file) expects a file to exist on which further lines can be appended. Use > instead to always create and overwrite the file.
Also... does nvflash open up a window(=GUI Window) or a command window (=console window like the one from cmd.exe). If it is the latter one, then nvflash internally does not write to standard out (that is, the already existing cmd window) but creates a new cmd.exe process to write to... in both cases the redirect with > or >> won't work :(

How to run Octave from a Notepad++ file line by line or by sections?

I am looking for a way to have my Notepad++ window open for editing my code and run it line by line or by sections (more than 1 line) while I am editing. It would be like having a real IDE; the output could be shown in the same window (Notepad++) or directly in the Octave window.
I have tried what many many sites say. That is, writing this:
C:\Software\Octave-3.6.4\bin\Octave\Octave-3.6.5.exe "$(FULL_CURRENT_PATH)"
in the Run window in Notepad++, saving and giving it a shortcut. However, it is still not working. When I tried to run it, the black window starts showing-up but then it disappears and nothing else happens. In my Notepad++ window I have only one line (for now) where I have tried just "b=4" or "3*4". I have done this with and without semicolon at the end. Nothing happens.
I have Windows 8.0, Notepad 6.5.5 and Octave-3.6.4. I already change the octaverc file in Octave to make it work with Notepad++. I have work already only in the command line in Octave and is working fine. The Octave I installed was exactly "octave-3.6.4-vs2010-setup", it says it was compiled for Visual Studio 10. Is that the reason why this is not working?
Any help will be appreciated...
regarding Octave not processing the command: use supposed command line outside the N++ and see if it works. If not, find a way to make it working, then transfer it back to N++ (and use the token "$(FULL_CURRENT_PATH)" instead of concrete filename)
regarding running the code in smaller portions: if you app can accept the code directly in the command line (SQL command line tools I use can do this), then you can use token "$(CURRENT_WORD)" what stands for content of current selection (all tokens are in wiki)

How to comfortably monitor variables in a VBscript during development process? (e.g. in a continuously opened command window)

I need to write a huge VBscript to automatically run an application and I'm looking for a way to comfortably monitor what I'm actually doing, in other words, to display the values of some/all variables involved in my script.
I'm used to work with Matlab, where I have a comfortable workspace browser. When I run a Matlab script, all variables, their types and their values are accessible in that workspace and can be checked.
The VBscript I write with Notepad++ (it needs to be a free editor) and the only way I found to display variables was echoing them via wscript and cscript.
I set up the shortcuts.xml with the following line to run my script directly from Notepad++:
<Command name="Run with CScript" Ctrl="yes" Alt="no" Shift="yes" Key="116">cmd /K %windir%\system32\cscript.exe "$(FULL_CURRENT_PATH)"</Command>
In case I include commands in my script like
Wscript.Echo myVar
Wscript.Echo "Hello World!"
and run it with the newly introduced shortcut, a cmd window pops up and displays the value of myVar and "Hello World!".
But the next time I run the script a new window pops up. So my question is:
Is it possible get a continuously opened output window, displaying all echoed values everytime I run a script? I actually want to put the window on a second screen and keep the values from previous runs. So I can enter a line Wscript.Echo something, run, check, enter something else and so on, without fiddling around with a bunch of opened windows.
Alternatively, is there any open-source/free editor which offers an accessible workspace like the one in Matlab?
The open-source editor SciTE offers what I was looking for.
The default settings in vb.properties enable a similar behavior like in Notepad++
command.build.$(file.patterns.wscript)=cscript "$(FilePath)"
command.build.subsystem.$(file.patterns.wscript)=1
One can change it as follows to get the output into the integrated console.
command.go.$(file.patterns.wscript)=cscript.exe //nologo "$(FilePath)"
command.go.subsystem.$(file.patterns.wscript)=0
F5 runs the script and Shift+F5 cleans the output.
Another option is the NppExec Plugin for Notepad++ suggested by #Ansgar Wiechers, which adds a console. The script can be run with cscript.exe /nologo "$(FULL_CURRENT_PATH)" then.
Use a debugger. Start your script with the (meta)option //X. If you are lucky, you already have installed software (MS Office, Visual Studio (Express)) that provides a debugger for VBScript. If not do a bit of research to find an Express version suitable to your OS.
You can almost write native VBScript in the VBA editor, so if you have Excel or whatever you can use this to debug, then go through some steps to convert back to VBScript. That's what I usually do.

Change keyboard input using Command Line

I would like to know whether is it possible to write a batch file that changes the default input language under windows XP What if the language is not installed ? For example, for some reason, My PC always starts with English as a default input language, and every time I have to go to control panel and reset it. I need to write a batch file that, when run, automatically adds french and make it the default one.
Thank you,
I don't think you can do this directly with a batch file, but you could write a simple app that did it and call that from your batch file. There's some useful info here:
http://msdn.microsoft.com/en-us/library/cc144191(VS.85).aspx

Resources