Why there is no output on asking input from user in lua using sublime text [duplicate] - input

This question already has answers here:
Can't send input to running program in Sublime Text
(5 answers)
Running Code in Sublime text 2 ( Mac OS X )
(1 answer)
Closed 2 years ago.
On initiating this program i got no output, not even the compiler asked me for input

You're supposed to submit text, not images.
That being said: Your script is fine, but Sublime pipes output to the editor, but isn't a full terminal, so doesn't allow input.
#! /usr/bin/env lua
io.write( 'Enter a number : ' )
local a = io.stdin:read('*n')
while a < 200 do
print( 'value of a :', a )
a = a +1
end
You'll have to open an actual terminal, cd into the relevant directory, then run your script.
chmod +x NAME_OF_SCRIPT.lua && ./NAME_OF_SCRIPT.lua
or
lua NAME_OF_SCRIPT.lua

Related

Windows command line script has embedded blank character [duplicate]

This question already has answers here:
What does %date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2% mean?
(2 answers)
Closed 4 years ago.
I want to copy a file to another file that contains the time and date
in its name.
I use the statement below but the problem is for time values earlier than 10 AM (for which the hour value is only a single digit) there is a blank character instead of a leading zero, which I want.
copy "M:\Production Schedule.xlsm" m:\gsdBackups\ProductionSchedule%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,0%.xlsm
In the example above when I run it at 9:50 I get the resulting name:
GSDProductionSchedule20180509_ 950.xlsm
I do not understand all of the formatting that is going on in the above copy command. Rather than the " 950" below I'd like to have "0950"
As a recurring task this should be a batch file hiding the details.
use wmic or PowerShell to get date/time in a user settings /locale independent format
name the batch file to any name with the extension .bat or .cmd and place it in a folder which is in the path
:: Q:\Test\2018\05\09\SO_50256566.cmd
#echo off
Set "Src=M:\Production Schedule.xlsm"
Set "Dst=M:\gsdBackups"
:: Get date and time in a user settinhs/locale independent format
For /f %%Y in ('
powershell -NoP -C "(get-date).AddDays(0).ToString('yyyyMMdd_HHmm')"
') Do Set _DT=%%Y
:: get source and use for variable modifiers to get name extension separated
For %%F in ("%Src%") Do echo copy "%%~F" "%Dst%\%%~nF_%_DT%%%~xF"
Sample output:
> SO_50256566.cmd
copy "M:\Production Schedule.xlsm" "M:\gsdBackups\Production Schedule_20180509_1743.xlsm"
If it looks OK to you remove the echo in front of copy.

Why does terminfo disagree with read? [duplicate]

This question already has an answer here:
Why is terminfo[kcuu1] = '\EOA'?
(1 answer)
Closed 5 years ago.
I'm using xterm. If I type infocmp $TERM | grep end, I see that kend=\EOF. However, if I type read, and then the End key, I see that the sequence \E[F is generated. This seems to be a problem with other keys, too.
Surely the values should be identical??
The terminal can be set on a special mode to send keystrokes from the keypad. You can set that mode by running tput smkx and unset it by tput rmkx.

Different result when build delphi project from command prompt and Delphi 10 Editor

I have problem with following code which is written in delphi-10. It excuted properly when it is build from Embarcadero Delphi 10 Editor but when i build module using Command Prompt it gives different result.
Command Prompt build result:
result of Screen.FormCount is zero but there are forms on second monitor
Delphi 10 Build Result:
result of Screen.FormCount is 1 and there is form on second monitor.(which is valid)
might be it is considering only first monitor when running from command prompt.
Monitor:= screen.Forms[Screen.FormCount].Monitor;
Self.Left := Monitor.Left + ((Monitor.Width - Self.Width) div 2);
Self.Top := Monitor.Top + ((Monitor.Height - Self.Height) div 2);
ShowMessage((screen.FormCount).ToString());
what should i do to work build with command prompt.
Hi #RemyLebeau i debug it again i found that when i build through IDE form count is 2 there are two form open one is from1 and second is MDIchildform but when i build through command prompt it gives form count 1 and only form1. may you please tell why MDIChildform is not consider in command prompt build,eve those both form are in same dll
if(screen.Forms[0].Name <>'') then
showmessage(screen.Forms[0].Name);
if(screen.FormCount >0) then
showmessage(screen.Forms[0].Name);
if(screen.FormCount >1) then
showmessage(screen.Forms[1].Name);

AMPL:How to print variable output using NEOS Server, when you can't include data and model command in the command file?

I'm doing some optimization using a model whose number of constraints and variables exceeds the cap for the student version of, say, AMPL, so I've found a webpage [http://www.neos-server.org/neos/solvers/milp:Gurobi/AMPL.html] which can solve my type of model.
I've found however that when using a solver where you can provide a commandfile (which I assume is the same as a .run file) the documentation of NEOS server tells that you should see the documentation of the input file. I'm using AMPL input which according to [http://www.neos-guide.org/content/FAQ#ampl_variables] should be able to print the decision variables using a command file with the appearance:
solve;
display _varname, _var;
The problem is that NEOS claim that you cannot add the:
data datafile;
model modelfile;
commands into the .run file, resulting in that the compiler cannot find the variables.
Does anyone know of a way to work around this?
Thanks in advance!
EDIT: If anyone else has this problem (which I believe many people have based on my Internet search). Try to remove any eventual reset; command from the .run file!
You don't need to specify model or data commands in the script file submitted to NEOS. It loads the model and data files automatically, solves the problem, and then executes the script (command file) you provide. For example submitting diet1.mod model diet1.dat data and this trivial command file
display _varname, _var;
produces the output which includes
: _varname _var :=
1 "Buy['Quarter Pounder w/ Cheese']" 0
2 "Buy['McLean Deluxe w/ Cheese']" 0
3 "Buy['Big Mac']" 0
4 "Buy['Filet-O-Fish']" 0
5 "Buy['McGrilled Chicken']" 0
6 "Buy['Fries, small']" 0
7 "Buy['Sausage McMuffin']" 0
8 "Buy['1% Lowfat Milk']" 0
9 "Buy['Orange Juice']" 0
;
As you can see this is the output from the display command.

Scripting an msdos program using a .bat file

i have a msdos program that when you execute it he ask you for 3 texts, you need to answer the firts, hit enter, then the second, hit enter and soo...
The think is that the answers are always the same, how using a .bat file can i script that? Thanks!
If the answers are always the same, you can (often) redirect the standard input to a text file containing the answers (one on each line, and there should be a newline after the last answer)
Program.exe -option1 -option2 < answers.txt
I say "often" because some programs will code around the standard input, like "runas".
answers.txt just looks like this:
answer1
answer2
answer3
In order to write a batch script to automate this task you would have to use a program that simulates key strokes in dos such as key-fake.
An alternative would be to use Windows Script Host which has this ability natively.
An example script (in javascript) would be something like:
var objShell = WScript.CreateObject("WScript.Shell");
var answer1 = a, answer2 = b, answer3 = c;
while(true) {
var myProg = Wscript.Exec("MyProgram");
WScript.Sleep = 100;
WScript.Echo(answer1);
WScript.SendKeys("{Enter}"); //Simulate Enter key
WScript.Echo(answer2);
WScript.SendKeys("{Enter}");
WScript.Echo(answer3);
WScript.SendKeys("{Enter}");
}
Save the script as myscript.js.
At a dos prompt run the following command:
cscript myscript.js
Press control-c to kill the script when you want it to stop.
To help you customize this script to your needs you can get more information here.