Menu
  • HOME
  • TAGS

Python - Passing input (prompt) into Function

python,input,prompt

The problem is that the input is outside the loop: import sys def inputSomething(prompt, errorMessage = 'Atleast one character must be used'): while True: value = input(prompt) Response = value.strip() if Response: print ('Valid') return Response else: print(errorMessage, file=sys.stderr) something = inputSomething('Enter str: ') Note that an empty string equates...

How to make a prompt box input invoke a function?

javascript,function,if-statement,prompt

If I understand correctly, you want the prompt to jump when the page is loaded, and then execute the code in "clickMe" (without the prompt) once the user has input a value? In that case, you need to run the prompt after the page has loaded. You can see an...

Prompt for 5 words then display longest word javascript

javascript,string,function,split,prompt

You are calling longestWord with string as a parameter, which is undefined. <script> function longestWord() { string = prompt("Enter a string of at least 5 words separated by spaces:") ; var str = string.split(" "); var longest = 0; str.forEach(function(str) { if (longest < str.length) { longest = str.length; word...

Javascript Prompt keeps appearing

javascript,prompt

Inside else, you need to set i>0. That will do it. Although, it's quite confusing here. What do you want to do? A simpler version would be, while(true){ //It will repeat indefinitely unlesss you break out of it var ounces = prompt("Enter number of Ounces: " , "0"); if (ounces...

Using Command Prompt to execute a java file

java,cmd,command,prompt

The .jar files are Java "libraries". What you need is something like: > javac ClassName.java > java -cp Library1.jar:Library2.jar ClassName.class The first line (javac) compiles the Java code into a class file. The second line runs the compiled class. The '-cp' option sets the CLASSPATH (makes the code in the...

Windows prompt content variable as variable name

windows,prompt

You need multiple rounds of expansion. See How does the Windows Command Interpreter (CMD.EXE) parse scripts? for an explanation as to why the following work: From the command line: call set "data=%%CURR%%" Or if delayed expansion has been enabled by cmd /v:on, then: set "data=!%CURR%!" From within a batch script:...

Get current directory (without full path) in Fish Shell

prompt,fish

Taken from @Jubobs' answer: basename is just a Unix utility; it's not associated to a particular shell, and should work equally well in Bash and Fish. It appeared I was using basename in the wrong context, and without a suffix. This was solved by using the following: function fish_prompt echo...

Any real difference between window.prompt and prompt?

javascript,prompt

Usually yes, window.prompt === prompt. Yet it does depend on your scope, someone might have declared window or prompt variables with different values than those in the global scope. For further details have a look at Is window really global in Javascript?. You (and your teacher) also might be interested...

how to reject duplicate values [closed]

python,duplicates,prompt

Store your numbers in a collection, such as a list. Then you can check if new numbers are already in the collection before adding more. integers = [] while len(integers) < 10: a = input("Enter an integer: ") if a in integers: print("Sorry, that number was already entered.") else: integers.append(a)...

Prompt command will not work in html [closed]

javascript,html,prompt

Your <script> type was your main problem. Remove type="javascript" and that is fixed. Also, the if statement should use == instead of =. Fix those two things and it'll work just fine. <script> var pass = prompt("What is the password") if (pass == "hack") { confirm("welcome"); } else { window.close();...

Run a bash script via another bash script to delete a file is not working properly

bash,command,prompt

You can run run.sh in the background using &. In start.sh, you would invoke the script via /path/run.sh &. Now, start.sh will exit without waiting for run.sh to finish (which is running in the background).

Python: Answer terminal prompt

python,prompt

Take a look at the pexpect module: https://pexpect.readthedocs.org/en/latest/

How to hide the hostname on the terminal on linux?

linux,terminal,prompt

If you want a temporary solution(since you are talking about a screencast), you can set your PS1 variable to change the prompt. For example, if you want your prompt to be: $ then set your PS1 variable as follows on the terminal: export PS1='$' Likewise, you can have it to...

CMD/Batch Prompting for Input loop without goto command

windows,loops,batch-file,cmd,prompt

You can't do this directly because of the way the FOR loop is processed. You can do it indirectly though. Look for the call-command: echo off setlocal for %%i in (*) do  call :Bar %%i goto :eof :Bar @echo %1 goto :eof :eof endlocal ...

Simplifying IF statement when comparing userInput from a prompt [duplicate]

javascript,if-statement,prompt,capitalization,capitalize

convert the user input userChoice to lower/upper case and then compare with a lower cased string like var userChoice = prompt("Choose either Rock, Paper, or Scissors.").toLowerCase(); if (userChoice !== "rock") { alert("Invalid response."); } ...

Javascript Prompt Validation?

javascript,validation,switch-statement,conditional-statements,prompt

loop: while(true){ var sport = prompt("What sport do you play? (Baseball, Football, Soccer, or Track)").toLowerCase(); switch (sport) { case "baseball": field = "Field 1"; break loop; case "football": field = "Field 2"; break loop; case "soccer": field = "Field 3"; break loop; case "track": field = "Field 4"; break loop;...

Assembly: je/jne after cmp causing error

assembly,command,prompt,16-bit

Nevermind, I figured it out. Totally not a fault of the code (hence the obvious confusion), it's the program -- it has a limit for how far you can jump in the byte indexes. Thanks, user.1, for answering, though.

sqlite3 weird behaviour after error

windows,sqlite3,prompt

The sqlite3 shell just waits for the end of the command, which would be indicated with a semicolon. It might also be necessary to close a string with ', or a trigger body with END;....

Write a Script to respond to prompts with specified text

osx,unix,ftp,terminal,prompt

A general solution is expect command. But for your task, it's an overkill. The ftp reads commands from a standard input. So just do: ftp -n < command.txt The -n prevents the automatic prompts for username/password. We provide these explicitly using user command below. The commands.txt file will look like:...

Java Program Loop won't Execute and Prompt User? [closed]

java,arrays,loops,while-loop,prompt

Don't do while (isValid = false). You're setting it to false! Instead do while (!isValid) { } Also, don't do while (isValid == false) -- that's ugly code. Next, change isValid inside the loop. while (!isValid) { // get input from user in here // test input and check if...

zsh inserts extra spaces when performing searches and completion

shell,command-prompt,zsh,prompt,ansi-escape

After doing some additional research, the ZSH Prompt Expansion docs indicate that escape literals need to be enclosed in %{...%}. This is bothersome since now I have to output those conditionally if I want the prompt program to work in other shells, but it seems to correct the behavior shown...

Open terminal/prompt and pass a comand (ping)

java,bash,cmd,terminal,prompt

You should search the documentation for your terminal for the option that sets the command that will be run on terminal startup. For example, for xterm it is -e, so to run a command from Java code in xterm you would do, for example: Runtime.getRuntime().exec("xterm -e ls;read"); // read is...

Angular display's literal in confirmation prompt

angularjs,syntax,prompt,confirmation

You should provide an expression inside ngClick directive, no need to interpolate it with {{}}: ng-click="confirmClick(lang.shopping_cart.clear_sc_prompt) && deleteShoppingCart()" ...

How to write a javaScript function to enter 2 numbers through prompts and display the sum of those numbers in an alert. Can anybody tell me on this?

javascript,input,prompt

To do it with only one prompt: var numbers = prompt("Enter two numbers separated by a semi-colon: ", ""); var a = numbers.split(";")[0]; var b = numbers.split(";")[1]; function calc(a,b) { return parseFloat(a) + parseFloat(b); } alert ("The addition of " + numbers + " is = " + calc(a,b)); ...

JavaScript prompt box: how to validate the cancel button (null)

javascript,validation,null,prompt

Your syntax is a bad here: if (T == false | T == "null") null shouldn't be a string, or is || not |. You also want to be checking if PetName is null, not the result of the regex. The line should look like this: if (!T || !PetName)...

Interactive command prompt in an event-driven application [closed]

c#,multithreading,events,console-application,prompt

It sounds like you are searching for gnu readline functionality. You can use LineEditor from mono as described here: http://tirania.org/blog/archive/2008/Aug-26.html.

How do you give an “alert = prompt” a variable? [closed]

javascript,prompt

You will need to be more specific, but I think what your getting at is something like this? var alert = prompt("Something in here"); But to get the best answers, be more specific and give some sample code (even if it doesn't work, it helps a lot)...

Retrieving user input and posting within HTML

javascript,html,prompt

Change your opening body tag to this: <body onload="placeName();"> Then, your JS file should look like this: function placeName(){ var name = prompt("Enter name"); if (name != null){ var greeting = "Hello " + player + "!"; document.getElementById("demo").innerHTML = greeting; } } You also need to make sure that you...

Ordinals java - Java I class

java,prompt,ordinals

In my opinion it would be better to move Scanner to main: public static void main(String[] args) { Ordinals number = new Ordinals(); Scanner input = new Scanner(System.in); while(true){ System.out.println("Enter an integer between 0 to 10: "); int i = input.nextInt(); System.out.println(i+number.Ordinals(i)); } } and then add to Ordinals: int...

Making a .bat in to find a public folder location. trouble making it ask the user to enter mailbox address

powershell,batch-file,prompt

Something like $emailAddress = Read-Host "Enter address:" Get-Recipient -Identity $emailAddress | Get-MailPublicFolder | Get-PublicFolder There's also a great resource here: http://waynes-world-it.blogspot.co.nz/2013/04/exchange-powershell-commands.html if that doesnt do it for you...

Excel VBA: Creating a confirmation prompt when a cell is edited

excel,excel-vba,prompt

There are two missing pieces to your solution. First, you need to store the value of the cell before it changed. Second, you need to connect to an event that tells you when the cell contents have changed. ' This is where you store the value before it was changed...

How to write an R function that displays plots sequentially?

r,plot,prompt,interactive,sequential

Just set par(ask=TRUE) before calling plot(). You might want to set it after your first plot, so the user doesn't have to wait for that one. To be nice, set par(ask=FALSE) after your last plot.

NodeJs Gulp - confirm before starting task

node.js,gulp,prompt,confirm

There's no need for a Gulp plugin, actually the package those two wrap around -- inquirer -- does anything you need: var inquirer = require('inquirer'); gulp.task('default', function(done) { inquirer.prompt([{ type: 'confirm', message: 'Do you really want to start?', default: true, name: 'start' }], function(answers) { if(answers.start) { gulp.start('your-gulp-task'); } done();...

How to hide password in phonegap prompt

android,cordova,passwords,hide,prompt

I found my answer on this thread. Set inputType for an EditText? Turns out you just need to add one line in App Name\platforms\android\src\org\apache\cordova\dialogs\Notification.java promptInput.setInputType(0x00000081); ...

How to prompt an SQL query user to input information

sql-server,variables,command-prompt,prompt

In case you can not do an application, you have no developers etc etc, you have one way - make a stored proc: create stored procedure spDoSomeJob @amon VARCHAR(2), @invdate DATE as begin ~~ rest of the code ~~ declare @sumA numeric(25, 5), @sumB numeric(25, 5), @ratio numeric(25, 5) select...

Why does my bash prompt sometimes get overwritten?

bash,prompt

Looks like you're including your $git_branch part in a non-printing-chars block (\[...\]).

Looping prompt on onclick

javascript,for-loop,prompt

From what I can see, the MySQL loop is irrelevant to the problem at hand, and the value of the variable j in appendTo("#div"+ j++) is scoped outside the loop, so is not what you expect by the time the onclick function is fired. So, a single loop is used...

automatically have script input yes at windows cmd yes/no prompt

windows,cmd,automation,registry,prompt

You could create a Yes.bat file with something like the following: @echo off for /L %%X in (1,1,77) do echo Yes (Replace 77 with some sufficiently large number) Then just run Yes.bat | YourCommand.bat It seems OK to have the Yes.bat command output more Yes's than required by YourCommand.bat. On...

Why my gdb prompt shows wrong after I change its color

linux,gdb,prompt

gdb manages command input by using the readline package. The way to tell readline that a character sequence in a prompt string doesn't actually move the cursor when output to the screen is to surround it with the markers RL_PROMPT_START_IGNORE (currently '\001' in readline's C header file) and RL_PROMPT_END_IGNORE (currently...

Dreamweaver - Don't update links on rename

settings,dreamweaver,prompt

In Preferences, there should be an option under General: 'Update links when moving files:' Change this to 'Never'. I believe this is what you're after....

Error assigning value to JavaScript class property

javascript,node.js,asynchronous,synchronization,prompt

You need to pass the scope of ageTotal into the prompt.get callback: var ageTotal = function(){ this.resultAge = 0; this.getUserAge = function(){ var that = this; prompt.start(); prompt.get(["age"], function(err, result){ that.resultAge += result.age }); } } ...

javascript prompt box without the cancel button?

javascript,jquery,javascript-events,prompt

Put your promt inside a while loop and continue asking for input until user gives any. do{ input = prompt("Give input"); }while(input == null || input == "" ); console.log(input); jsFiddle [Note : It's a way to fulfill your requirement that I won't suggest as it may annoy user. You...

How do I use gets/chomp in ruby to login in account without display strings in terminal? [duplicate]

ruby,io,gem,gmail,prompt

There are a few gems which can do what you want - one of them is password: Ruby/Password is a collection of password handling routines for Ruby, including an interface to CrackLib for the purposes of testing password strength. require 'password' # Define and check a password in code pw...

Animated PS1 prompt BASH [duplicate]

linux,bash,unix,prompt,ps1

This is what I got: animation() { S="\033[s" U="\033[u" POS="\033[1000D\033[2C" while [ : ] do eval echo -ne '${S}${POS}\>\ \ ${U}' sleep 0.3 eval echo -ne '${S}${POS}\ \>\ ${U}' sleep 0.3 eval echo -ne '${S}${POS}\ \ \>${U}' sleep 0.3 done } PS1='[ ] : [ \u @ \h ] >...

Bash Prompt Wrapping Issue

bash,prompt

All non-printing segments in the must be surrounded by \[...\] and all printing segments must not be surrounded by those. You have at least one space inside \[...\] near the end. You also have a large number of unclosed \[ (count your matched pairs). Using variables for the color codes...

How to handle browser prompts in CasperJS

javascript,phantomjs,casperjs,prompt

You can easily solve this by using a Filter in CasperJS. The appropriate one is page.prompt: // put somewhere before the prompt appears casper.setFilter("page.prompt", function(msg, currentValue) { if (msg === "What's your name?") { return "Chuck"; } }); Such a dialog is called a prompt (window.prompt()) which is distinct from...

Python: How do you get a programme to prompt the user a certian fixed amount of times for a user input?

python,python-3.x,input,passwords,prompt

try this: import sys max_tries = 3; current_tries = 0 password=input("Enter password:") while password != 'cat': if current_tries > max_tries: print "too many tries" sys.exit(0) print ("password is wrong, try it again") password= input ("Enter your password:") current_tries +=1 print ("Password correct be happy") ...

cmd line prompt for navigating to only folder in current folder. Windows

windows,command-line,navigation,folder,prompt

There's not really a simple command for this. Like you suggested, the best solution, and what I would do, is cdspaceTab. Strictly speaking, there is a command that satisfies your requirements, but it's not exactly easy under the fingers. for /d %I in (*) do cd "%I" which would loop...

Java: Add Place Holder on JTextField

java,swing,jtextfield,prompt

Check out Text Prompt for a flexible solution. You can control when prompt is displayed (always, focus gained or focus lost). You can also customize the style of the text....

IMacros: How to use Prompt with javascript

javascript,prompt,imacros

var x='PROMPT \"Page\" '; document.getElementById("demo").innerHTML = x ; <p id="demo"></p> Check the code and adjust according to that...

VBA - on click - generate a prompt to confirm which workbook / spreadsheet to look at

excel,vba,onclick,copy,prompt

I think that the best way would be to create a UserForm with 2*2 comboboxes (1 for workbooks (here Cb_Wb) and one for sheets (here Cb_Ws), 2 times : source and destination) With that code : Private Sub Cb_Wb_Change() Me.Cb_Ws.Clear On Error Resume Next For Each ws In Workbooks(Me.Cb_Wb.Value).Worksheets Me.Cb_Ws.AddItem...

ALERT Box not showing up, issue within code, not browser

javascript,html,prompt

You are missing a closing bracket on your if statement: if(user_password == password(checkFor)) <<<<< I recommend checking your javascript code with something like http://www.jshint.com if your debugger/IDE isnt picking it up....

Mac applescript - ask for administrator privileges prompt

applescript,prompt,privileges,administrator

If you make your AppleScript an application (in Script Editor, go File>Save as…>Type "Application"), you can then set an icon and a user-friendly name. Save the application with the name that you want to appear in the alert window (replacing "osascript). Set an icon by opening the new application's package,...

vim script leaves characters in stdin

bash,vim,vi,prompt

It seems like vim (or some vim startup script) is trying to figure out what type of terminal you are using. The ^[[?1;2c, with the last few characters left in the input buffer, is almost certainly part of your terminal emulator's response to a DA (Device Attributes) query. You can...

cURL - prompt script works while same request with curl-php doesn't (Internal server error 500)

php,curl,login,prompt

I forgot to add the user agent to the two php Pages. I just deleted the comment option from the two script. This solved my problem

Echo command cuts new lines

bash,echo,command-prompt,prompt,cat

You just need to use: apt-cache search nano > search There is no need to use echo and command substitution which is stripping newlines to a space due to absence of quotes around your command....

How to “if not an integer , alert and repeat prompt” ? the same with isNAN

javascript,alert,prompt,fizzbuzz

the logical order of your if statements and loop is incorrect for what you are trying to achieve. you want to first check if this number is a number, then you want to check if tis a whole number, then you want to enter the for loop if it passes...

Checking if user has unsaved data in JQuery?

javascript,jquery,exit,prompt

Some information about the logic I have followed: This code doesn't save anything, if you need to store some information just with JS, so on the client computer and this will depend on the cache, you can use the cookie(the information are temporary since rely on cookies that can be...

adding text after prompt for input

java,input,cmd,prompt

We can use \r in a tricky way: import java.util.Scanner; public class JavaApplication2 { public static void main(String[] args) { int i=0; Scanner s = new Scanner(System.in); System.out.print("Enter num: __kg\r"); System.out.print("Enter num: "); i = s.nextInt(); System.out.println("\n"+i); } } How it works: we print Enter num: __kg and \r to...