Jamie2312 Posted May 19, 2006 Share Posted May 19, 2006 Hey everyone, I am trying to write a program, in which can open a text file uploaded to a website. This is the coding I have so far:$passcorrect = FileOpen("http://users.tpg.com.au/gmack60/password.txt", 0); Check if file opened for reading OKIf $passcorrect = -1 Then MsgBox(0, "Error", "Unable to open password file. Please try again later.") ExitEndIf While 1 $data = FileReadLine($passcorrect), 1)) If @error = -1 Then ExitLoopWEndFileClose($passcorrect)$password = String(InputBox("Control Centre","Please enter password to access this program:"))If $password <> $data Then MsgBox(4096,"Incorrect Password","Incorrect Password... Good bye!",0) EXITCould anyone tell me what is wrong with my coding? Thanks! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 Hey everyone, I am trying to write a program, in which can open a text file uploaded to a website. This is the coding I have so far:$passcorrect = FileOpen("http://users.tpg.com.au/gmack60/password.txt", 0); Check if file opened for reading OKIf $passcorrect = -1 Then MsgBox(0, "Error", "Unable to open password file. Please try again later.") ExitEndIf While 1 $data = FileReadLine($passcorrect), 1)) If @error = -1 Then ExitLoopWEndFileClose($passcorrect)$password = String(InputBox("Control Centre","Please enter password to access this program:"))If $password <> $data Then MsgBox(4096,"Incorrect Password","Incorrect Password... Good bye!",0) EXITCould anyone tell me what is wrong with my coding? Thanks!You have to download the .txt file first, take a look at InetGet() in the help file. (I can't remember if it's Beta or release)If it's in Beta than download that here:http://www.autoitscript.com/forum/index.php?showtopic=19717 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...
Jamie2312 Posted May 19, 2006 Author Share Posted May 19, 2006 (edited) You have to download the .txt file first, take a look at InetGet() in the help file. (I can't remember if it's Beta or release)If it's in Beta than download that here:http://www.autoitscript.com/forum/index.php?showtopic=19717Thanks, Ill try and code it now but if you could post what you would do (for this example), that would be great...UPDATE: Its a password file so where should I download it to, so a novice user would not find it??? Edited May 19, 2006 by Jamie2312 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 Thanks, Ill try and code it now but if you could post what you would do (for this example), that would be great...UPDATE: Its a password file so where should I download it to, so a novice user would not find it???Well if you looked at my desktop at the moment, I wouldn't find it there , most people use @TempDir and then FileDelete() it once it's been read. 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...
Jamie2312 Posted May 19, 2006 Author Share Posted May 19, 2006 (edited) Well if you looked at my desktop at the moment, I wouldn't find it there , most people use @TempDir and then FileDelete() it once it's been read.lol... I put in your suggestion (inetget) but for some reason its not working - could you modify the below code so it will work with the TempDir and FileDelete() in it...InetGet("http://users.tpg.com.au/gmack60/password.txt", "password.txt", 1, 1)$passcorrect = FileOpen("password.txt", 0); Check if file opened for reading OKIf $passcorrect = -1 Then MsgBox(0, "Error", "Unable to open password file. Please try again later.") ExitEndIf While 1 $data = FileReadLine($passcorrect), 1) If @error = -1 Then ExitLoopWEndFileClose($passcorrect)$password = String(InputBox("Control Centre","Please enter password to access this program:"))If $password <> $data Then MsgBox(4096,"Incorrect Password","Incorrect Password... Good bye!",0) EXITElseThanks so much! Edited May 19, 2006 by Jamie2312 Link to comment Share on other sites More sharing options...
nfwu Posted May 19, 2006 Share Posted May 19, 2006 (edited) InetGet("http://users.tpg.com.au/gmack60/password.txt", @TempDir & "\110~pass2203.txt") $passcorrect = FileOpen(@TempDir & "\110~pass2203.txt", 0) ; Check if file opened for reading OK If $passcorrect = -1 Then MsgBox(0, "Error", "Unable to open password file. Please try again later.") Exit EndIf While 1 $data = FileReadLine($passcorrect), 1)) If @error = -1 Then ExitLoop WEnd FileClose($passcorrect) FileDelete(@TempDir & "\110~pass2203.txt") $password = String(InputBox("Control Centre","Please enter password to access this program:")) If $password <> $data Then MsgBox(4096,"Incorrect Password","Incorrect Password... Good bye!",0) EXIT EndIf #) Edit: Forgot the EndIf Edited May 19, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Jamie2312 Posted May 19, 2006 Author Share Posted May 19, 2006 (edited) Its coming up with an error on line 12 still - $data = FileReadLine($passcorrect), 1)). (The endif was at the end of the program which i didnt include as it is fairly lengthy) Edited May 19, 2006 by Jamie2312 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 (edited) Its coming up with an error on line 12 still - $data = FileReadLine($passcorrect), 1)). (The endif was at the end of the program which i didnt include as it is fairly lengthy)Take off the extra ")" after FileReadLine and after $passcorrect on the same line:InetGet("http://users.tpg.com.au/gmack60/password.txt", @TempDir & "\110~pass2203.txt") $passcorrect = FileOpen(@TempDir & "\110~pass2203.txt", 0) ; Check if file opened for reading OK If $passcorrect = -1 Then MsgBox(0, "Error", "Unable to open password file. Please try again later.") Exit EndIf While 1 $data = FileReadLine($passcorrect, 1) If @error = -1 Then ExitLoop WEnd FileClose($passcorrect) FileDelete(@TempDir & "\110~pass2203.txt") $password = String(InputBox("Control Centre","Please enter password to access this program:")) If $password <> $data Then MsgBox(4096,"Incorrect Password","Incorrect Password... Good bye!",0) Exit EndIfEdit: Also when posting code, rather than using the "Bold" ust the [code ] [/code ] tags (without spaces), makes it easier to read. Edited May 19, 2006 by SmOke_N 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...
Jamie2312 Posted May 19, 2006 Author Share Posted May 19, 2006 Its still coming up with the same error once i took off the extra ) - illegal text, one statement per line Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 Its still coming up with the same error once i took off the extra ) - illegal text, one statement per lineRead my edit: 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...
Jamie2312 Posted May 19, 2006 Author Share Posted May 19, 2006 (edited) Read my edit:Thanks, somethings happening but the script is pausing for some reason - why is this? Is my firewall blocking the download or something? or is it the positioning of my endif (at the very end of program) Edited May 19, 2006 by Jamie2312 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 (edited) You're stuck in the While 1 loop because you are only ever reading line 1 so it's never an errorInetGet("http://users.tpg.com.au/gmack60/password.txt", @TempDir & "\110~pass2203.txt") $passcorrect = FileOpen(@TempDir & "\110~pass2203.txt", 0) ; Check if file opened for reading OK If $passcorrect = -1 Then MsgBox(0, "Error", "Unable to open password file. Please try again later.") Exit EndIf $data = FileReadLine($passcorrect, 1) If @error = - 1 Then Exit FileClose($passcorrect) FileDelete(@TempDir & "\110~pass2203.txt") $password = String(InputBox("Control Centre","Please enter password to access this program:")) If $password <> $data Then MsgBox(4096,"Incorrect Password","Incorrect Password... Good bye!",0) Exit EndIf Edited May 19, 2006 by SmOke_N 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...
Jamie2312 Posted May 19, 2006 Author Share Posted May 19, 2006 You're stuck in the While 1 loop because you are only ever reading line 1 so it's never an errorInetGet("http://users.tpg.com.au/gmack60/password.txt", @TempDir & "\110~pass2203.txt") $passcorrect = FileOpen(@TempDir & "\110~pass2203.txt", 0) ; Check if file opened for reading OK If $passcorrect = -1 Then MsgBox(0, "Error", "Unable to open password file. Please try again later.") Exit EndIf $data = FileReadLine($passcorrect, 1) If @error = - 1 Then Exit FileClose($passcorrect) FileDelete(@TempDir & "\110~pass2203.txt") $password = String(InputBox("Control Centre","Please enter password to access this program:")) If $password <> $data Then MsgBox(4096,"Incorrect Password","Incorrect Password... Good bye!",0) Exit EndIf Yey, its working! Thanks everyone for your help... Youve been great. Sorry guys but this is my first time at autoit Thanks again... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 Yey, its working! Thanks everyone for your help... Youve been great. Sorry guys but this is my first time at autoitThanks again...Good... you did pretty good for your first time out couple of issues, but easily fixable if you know the functions and what the errors are for, I might suggest trying out Valuaters AutoIt 123 to help speed things along for you if you haven't already.http://www.autoitscript.com/forum/index.php?showtopic=21048 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...
Jamie2312 Posted May 19, 2006 Author Share Posted May 19, 2006 Thanks, Ill have a look at it Link to comment Share on other sites More sharing options...
Confuzzled Posted May 20, 2006 Share Posted May 20, 2006 Hey everyone, I am trying to write a program, in which can open a text file uploaded to a website. This is the coding I have so far:$passcorrect = FileOpen("http://users.tpg.com.au/gmack60/password.txt", 0); Check if file opened for reading OKIf $passcorrect = -1 ThenMsgBox(0, "Error", "Unable to open password file. Please try again later.")ExitEndIf While 1$data = FileReadLine($passcorrect), 1))If @error = -1 Then ExitLoopWEndFileClose($passcorrect)$password = String(InputBox("Control Centre","Please enter password to access this program:"))If $password <> $data ThenMsgBox(4096,"Incorrect Password","Incorrect Password... Good bye!",0)EXITCould anyone tell me what is wrong with my coding? Thanks! Um, now that the entire Internet knows where you store your password, you should change the location of the file and the contents of the current one, and all sites where you have used the current one. 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