Questions tagged [user-input]

User Input is data that the user inputs into the program. It generally takes the form of a String, but may also be an integer, floating-point number, etc.

5580 questions
8
votes
6 answers

Programming style question on how to code functions

So, I was just coding a bit today, and I realized that I don't have much consistency when it comes to a coding style when programming functions. One of my main concerns is whether or not its proper to code it so that you check that the input of the…
shawnjan
  • 959
  • 7
  • 16
8
votes
3 answers

Removing non-alphanumeric characters from a string

I have a string in PHP and I want it to match the regex [A-Za-Z0-9]. How can I do this?
Malfist
  • 31,179
  • 61
  • 182
  • 269
8
votes
6 answers

How to make a window with buttons in python

How do I create a function that makes a window with two buttons, where each button has a specified string and, if clicked on, returns a specified variable? Similar to @ 3:05 in this video…
user2874724
  • 97
  • 1
  • 1
  • 8
8
votes
7 answers

Check if the input is a number or string in C++

I wrote the following code to check whether the input(answer3) is a number or string, if it is not a number it should return "Enter Numbers Only" but it returns the same even for numbers. Please suggest me a solution. #include #include…
Rukshan Mahendra
  • 113
  • 1
  • 1
  • 7
8
votes
4 answers

how do I wait on console input in c# for 15 seconds or so

I need to ask for input in console and wait for few sec may be a min after that I need to default to some value. How can basically time our on console input in c# and proceed with default settings? If you have sample code that would be great.
Prache
  • 533
  • 1
  • 6
  • 8
8
votes
2 answers

How does Python populate a string from argparse

I'm curious about what goes on behind the scenes when using argparse. I've checked here and here, as apparently Namespace presently only exists in the argparse library. It's possible I'm using the wrong keywords to search SO/Google. It's also…
hitjim
  • 93
  • 6
8
votes
4 answers

html5 input pattern attribute not working outside a form?

this fiddle works as intended - it displays a warning when the user enters an invalid country code. This other fiddle, without the form element, doesn't work. It seems the input's pattern attribute needs a form to validate. By the way, I'm doing a…
janesconference
  • 6,333
  • 8
  • 55
  • 73
8
votes
2 answers

Auto Complete User Input PowerShell 2.0

I have a large list of data (over 1000 different values) and I want the user to be able to select certain values from the list from a PowerShell console. What is the easiest way from within the console to allow the user to quickly select values? I…
esap120
  • 178
  • 1
  • 1
  • 11
8
votes
1 answer

Read keyboard input in Scala with the typed characters visible

I know about readInt and readLine similar methods for reading input from the keyboard and am able to populate variables with the data typed by the user. But in the REPL nothing is displayed when the characters are being typed. Is there a setting in…
Gigatron
  • 1,995
  • 6
  • 20
  • 27
8
votes
2 answers

How to detect user presence in android?

I know in Galaxy Samsung SIII it is possible to configure in settings an option to avoid the screen turns off when user is looking into the screen. I think the phone uses the camera or a kind of a sensor of presence. is it possible to do it…
Felipe
  • 16,649
  • 11
  • 68
  • 92
8
votes
3 answers

How to take user input in the same line?

I'm bigener in C# programming So, I was just wondering about how to take user input in the same line? this is my code and also I want to print the output in the same line using System; namespace Wa2 { class BodyMassCalculation { public…
user1692696
  • 83
  • 1
  • 1
  • 3
7
votes
1 answer

Wait for user input when running an R script in Linux

I am have a piece of code that prompts for user input and works perfectly fine in while running the code in Windows. However, in Linux, it executes every line without waiting for user input. I have added the code in a separate function and used…
agatha
  • 1,513
  • 5
  • 16
  • 28
7
votes
1 answer

Ensure a user-defined path is safe in PHP

I am implementing a simple directory listing script in PHP. I want to ensure that the passed path is safe before opening directory handles and echoing the results willy-nilly. $f = $_GET["f"]; if(! $f) { $f = "/"; } // make sure $f is safe $farr…
user47322
7
votes
1 answer

Which are safe methods and practices for string formatting with user input in Python 3?

My Understanding From various sources, I have come to the understanding that there are four main techniques of string formatting/interpolation in Python 3 (3.6+ for f-strings): Formatting with %, which is similar to C's printf The str.format()…
7
votes
2 answers

How to make string input in Assembly language?

Please, does anybody know how to code string input in assembly language? I'm using int 21 to display and input characters.
AlbatrosDocsCoder
  • 149
  • 2
  • 4
  • 12