| 1. |
Solve : Is there a way to detect a carriage return from user input?? |
|
Answer» Hello, If you hit another letter like G, it handles the error correctly, but it can't handle a carriage return.Both are handled that same way. Why do you say it does not handle the CR correctly? G is not Y or y or N or n. And neither is CR. Anything other than Y y N n loops in INPUT2. Quote from: Geek-9pm on January 14, 2010, 12:46:32 PM Your program looks alright.EDIT: I stand corrected. CR retains the last value.If you have set /p answer=Prompt? and the user hits ENTER, the test "%answer%"=="" returns true No, teh CR does not git a null. gpl got it right. You have to set the thing to a null before you make the test. Only then CR will give null, because it already was null.Quote from: Geek-9pm on January 14, 2010, 03:23:34 PM You have to set the thing to a null before you make the test. You mean like this? Code: [Select]@echo off set answer=&set /p answer=Your input? if "%answer%"=="" ( echo String: ENTER ) else ( echo String: %answer% ) But we need a loop to verify it. set answer=&set /p does clear it to null, otherwise it would retain its prior value when the user hits return Code: [Select]@ECHO QUIT or PARTY @ECHO OFF :PARTY1 set answer=&set /p answer=Your input ? IF "%answer%"=="" ( echo ENTER ) ELSE ( echo %answer% ) if "%answer%"=="PARTY" ( goto PARTY1 ) Thank You!@OP, don't have to make things so complicated. Use an infinity loop. something like this. Code: [Select]:LOOP 1) ask for input 2) if input not "Y", "y","N","n" blah -- goto LOOP 3) else breakHey guys, Thanks for all of the replies and suggestions. gpl's suggestion seemed the simplest to implement. I added the line below exactly where he said to, and the program works perfectly now, thanks to all of you, but special thanks to gpl. Quote from: gpl on January 14, 2010, 12:40:50 PM For anybody who is interested in creating a program to view website address information here is my final version. You'll need to download the WHOIS utility from here http://technet.microsoft.com/en-us/sysinternals/bb897435.aspx Place the WHOIS.exe in the C:\WINDOWS\system32 folder Create a new .txt file on the desktop Paste the code below into the .txt file echo off title WHOIS LOOKUP ::INPUT 1 SCREEN :INPUT1 cls echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. set/p "input1=> ENTER THE WEBSITE ADDRESS > " ::LOOKUP SCREEN :LOOKUP cls WHOIS %input1% pause ::INPUT 2 SCREEN :INPUT2 cls echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. echo. set input2=error set/p "input2=> WOULD YOU LIKE TO LOOK UP ANOTHER ADDRESS? (Y/N?) > " if %input2%==Y goto YES if %input2%==y goto YES if %input2%==N goto END if %input2%==n goto END goto INPUT2 :YES goto INPUT1 :END exit Change the .txt extention to .bat Once you run it, you might want to change the command prompt properties to view it fullscreen. Right-click on the blue title-bar at the top of the command prompt window, select Properties, then the Options tab. Select the Window radial button. Select the Layout tab. Set the Screen Buffer Size: Width to 100, Height to 100. Set the Window Size: Width to 125, Height to 54 Set the Window Position: Width to 0, Height to 0 Those settings seem to fit a 1024 x 768 screen well. Here is an example of what is displayed if you look up www.yahoo.com Whois v1.01 - Domain information lookup utility Sysinternals - www.sysinternals.com Copyright (C) 2005 Mark Russinovich Connecting to COM.whois-servers.net... Connecting to COM.whois-servers.net... Connecting to whois.markmonitor.com... MarkMonitor is the Global Leader in Enterprise Brand Protection. Domain Management MarkMonitor Brand ProtectionΓäó AntiFraud Solutions Corporate Consulting Services Visit MarkMonitor at www.markmonitor.com Contact us at 1 800 745 9229 In Europe, at +44 (0) 20 7840 1300 The Data in MarkMonitor.com's WHOIS database is provided by MarkMonitor.com for information purposes, and to assist persons in obtaining information about or related to a domain name registration record. MarkMonitor.com does not guarantee its accuracy. By submitting a WHOIS query, you agree that you will use this Data only for lawful purposes and that, under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail (spam); or (2) enable high volume, automated, electronic processes that apply to MarkMonitor.com (or its systems). MarkMonitor.com reserves the right to modify these terms at any time. By submitting this query, you agree to abide by this policy. Registrant: Domain Administrator Yahoo! Inc. 701 First Avenue Sunnyvale CA 94089 US [emailprotected] +1.4083493300 Fax: +1.4083493301 Domain Name: yahoo.com Registrar Name: Markmonitor.com Registrar Whois: whois.markmonitor.com Registrar Homepage: http://www.markmonitor.com Administrative Contact: Domain Administrator Yahoo! Inc. 701 First Avenue Sunnyvale CA 94089 US [emailprotected] +1.4083493300 Fax: +1.4083493301 Technical Contact, Zone Contact: Domain Administrator Yahoo! Inc. 701 First Avenue Sunnyvale CA 94089 US [emailprotected] +1.4083493300 Fax: +1.4083493301 Created on..............: 1995-01-18. Expires on..............: 2012-01-18. Record last updated on..: 2009-12-02. Domain servers in listed order: ns5.yahoo.com ns3.yahoo.com ns2.yahoo.com ns1.yahoo.com ns4.yahoo.com MarkMonitor is the Global Leader in Enterprise Brand Protection. Domain Management MarkMonitor Brand ProtectionΓäó AntiFraud Solutions Corporate Consulting Services Visit MarkMonitor at www.markmonitor.com Contact us at 1 800 745 9229 In Europe, at +44 (0) 20 7840 1300 -- Press any key to continue . . . Pretty cool huh? Well thanks to everybody for the help, and I hope that my little program simplifies looking up website information with the WHOIS utility for somebody out there. |
|