Robin Posted April 3, 2009 Share Posted April 3, 2009 (edited) How can i make a veriable to take ANY input? For example my $input must be able to accept c:\ and rest to follow as TRUE. For instance, the "C:\" part MUST be in the input box, otherwise it wont work. I have tried $var2 <>, but it doesnt accept it. $var1 = "c:\" $var2 = "" <--- here lies the prob $input1 = InputBox("Testing", "Enter c:\ plus anything else to check if your stuff works.", "", "") if $input1 =("c:\"& $var2 ) Then MsgBox(0,"","als well") else MsgBox(0,"","oops") endif Edited April 3, 2009 by Robin Link to comment Share on other sites More sharing options...
BrettF Posted April 3, 2009 Share Posted April 3, 2009 Maybe start by explaining the purpose... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Robin Posted April 3, 2009 Author Share Posted April 3, 2009 (edited) Maybe start by explaining the purpose...Hi BrettF...I want ppl to input a Full Directory...ie C:\my docs...The program must now check if the guy has put in the correct Drive, otherwise it wont except the input...Thats why i made $var1 = "C:\"...The other "$var" must accept anything... Edited April 3, 2009 by Robin Link to comment Share on other sites More sharing options...
Spiff59 Posted April 3, 2009 Share Posted April 3, 2009 If StringLeft($Inputbox, 3) = $var1 Then ... Link to comment Share on other sites More sharing options...
Robin Posted April 3, 2009 Author Share Posted April 3, 2009 (edited) If StringLeft($Inputbox, 3) = $var1 Then ...thx Spiff59...works like a charm Out of curiosity...Can a person make a veriable to accept any input? Edited April 3, 2009 by Robin Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 3, 2009 Moderators Share Posted April 3, 2009 thx Spiff59...works like a charm Out of curiosity...Can a person make a veriable to accept any input?A standard autoit variable could accept any type of data. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Robin Posted April 3, 2009 Author Share Posted April 3, 2009 (edited) A standard autoit variable could accept any type of data.I hear what youre saying SmOke, but what i mean is, if you look at my very first post here, i had $var2 = ""I was under the impression that "" = Anything or ANY input... But when i used it in my script, AutoIt didnt except it... Edited April 3, 2009 by Robin Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2009 Moderators Share Posted April 3, 2009 (edited) Robin,When you create your InputBox you set the contents to "". So when you check if the contents = "c:\" & $var2 of course it will fail! If you were to do this:$var1 = "c:\" $var2 = "" $input1 = InputBox("Testing", "Enter c:\ plus anything else to check if your stuff works.", $var1, "") if $input1 =($var1 & $var2 ) Then MsgBox(0,"","alls well") else MsgBox(0,"","oops") endifyou will find that it does work as you expect - as far as your code goes.However, "" does not mean "anything" - it means NUL or nothing. So it will not work as you thought it would because any additional input would render the If false again:c:\fred is the same as $var1 & "fred" which is not the same as $var1 & "" because that is just "c:\"I hope that is clear.M23Edited because I pressed "Post" and not "Preview" Edited April 3, 2009 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Robin Posted April 3, 2009 Author Share Posted April 3, 2009 Robin, When you create your InputBox you set the contents to "". So when you check if the contents = "c:\" & $var2 of course it will fail! If you were to do this:$var1 = "c:\" $var2 = "" $input1 = InputBox("Testing", "Enter c:\ plus anything else to check if your stuff works.", $var1, "") if $input1 =($var1 & $var2 ) Then MsgBox(0,"","alls well") else MsgBox(0,"","oops") endif you will find that it does work as you expect - as far as your code goes. However, "" does not mean "anything" - it means NUL or nothing. So it will not work as you thought it would because any additional input would render the If false again: c:\fred is the same as $var1 & "fred" which is not the same as $var1 & "" because that is just "c:\" I hope that is clear. M23 Edited because I pressed "Post" and not "Preview"Cleared up...thx m23 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now