Jump to content

small problem $var must be anything


Recommended Posts

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 by Robin
Link to comment
Share on other sites

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 by Robin
Link to comment
Share on other sites

If StringLeft($Inputbox, 3) = $var1 Then ...

thx Spiff59...works like a charm :D

Out of curiosity...Can a person make a veriable to accept any input?

Edited by Robin
Link to comment
Share on other sites

  • Moderators

thx Spiff59...works like a charm :D

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

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 by Robin
Link to comment
Share on other sites

  • Moderators

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"

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...