KnowledgeSponge Posted July 28, 2004 Posted July 28, 2004 (edited) I know where the fundamental problem is with this, I just came seem to see how to fix it. Can anyone help me out? expandcollapse popup$linenumber = 0; $chosenfile = InputBox("Location","Please enter the remote file location","") $saveas = FileSaveDialog ( "Save to", "D:\Downloads\", "All(*.*)", 16 ) URLDownloadToFile($chosenfile,$saveas) $openit = MsgBox(4,"Download Complete!","Open " & $saveas & "?") If $openit = 6 Then Global $charstoremove = StringInStr ( $saveas , ".") Global $filetypeget = StringTrimLeft ( $saveas, $charstoremove ) $file = FileOpen("D:\Miscellaneous\Scripts\filetypes.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $linenumber = $linenumber + 1 $recognizedtype = FileReadLine($file , $linenumber) If @error <> 0 Then FileClose($file) $file = FileOpen("D:\Miscellaneous\Scripts\filetypes.txt", 1) $newtype = FileSaveDialog ( "Select the Program to Run", "C:\", "EXE Files (*.exe)", 1 ) If @error = 1 Then MsgBox(0,"No File Selected", "No File Selected. The program cannot continue.") Exit EndIf FileWrite ( $file , $filetypeget & "=" & $newtype & "|" ) $checktypes = FileOpen("D:\Miscellaneous\Scripts\filetypes.txt", 0) $recognizedtype = FileReadLine($checktypes, $linenumber) EndIf $evalstrr = StringInStr($recognizedtype, "|") $stripit = 3 - $evalstrr MsgBox(0,"No File Selected", $stripit) $gettype = StringTrimRight($recognizedtype, $stripit) MsgBox(0,"No File Selected", $gettype) If $gettype = $filetypeget Then $getprogloc = StringTrimLeft($recognizedtype, $evalstrl) EndIf If $recognizedtype = $filetypeget Then $LLOC = '"' & $getprogloc & '"' $PARAM = '"' & $saveas & '"' Run($LLOC & " " & $PARAM) Exit EndIf Wend EndIf Exit The problem lies here $evalstrr = StringInStr($recognizedtype, "|") $stripit = 3 - $evalstrr MsgBox(0,"No File Selected", $stripit) $gettype = StringTrimRight($recognizedtype, $stripit) MsgBox(0,"No File Selected", $gettype) If $gettype = $filetypeget Then $getprogloc = StringTrimLeft($recognizedtype, $evalstrl) Not sure how to fix it. Would appreciate if someone could show me. Thanks alot. *edit* I left a couple of lines i was using to debug in there and a few remnants from changing things around to see if i was just lookin at it wrong. Just ignore them. Edited July 28, 2004 by KnowledgeSponge
emmanuel Posted July 28, 2004 Posted July 28, 2004 (edited) well, I ran the au3 syntax checker on it, here's what it returns:AutoIt3 Syntax Checker v1.07, Copyright © Tylo, 2004(35,61) : WARNING: $evalstrl: possible used before declaration. $getprogloc = StringTrimLeft($recognizedtype, $evalstrl)(35,61) : ERROR: $evalstrl: undeclared global variable. $getprogloc = StringTrimLeft($recognizedtype, $evalstrl)you're not setting $evalstrl anywhere in there.Edit: crap, sorry, you knew that.though, looks like you're defining $evalstrr and calling $evalstrl? Edited July 28, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks)
emmanuel Posted July 28, 2004 Posted July 28, 2004 (edited) and, you've got alot of hard coded stuff in the script that I just plain don't have, "D:\Miscellaneous\Scripts\filetypes.txt"? I inserted a debug msgbox on $evalstrr and it never popped up. $evalstrr = StringInStr($recognizedtype, "|") MsgBox(4096,'debug:' , '$evalstrr:' & $evalstrr);### Debug MSGBOX sidenote, hitting cancle on a dialog should quit the script, or do something else. Edited July 28, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks)
KnowledgeSponge Posted July 28, 2004 Author Posted July 28, 2004 Yeah i had it evalstrr - evalstrl after doin stringinstr looking for | and = to separate and get the amount of chars to leave the file type in the text file. But it was returning a null value. For some reason I can't get that to work correctly. For example you choose file say notepad as the program to run the file type. it writes txt=C:\Program Files\Notepad.exe| or whatever to the text file, then compares the results and loads the file with that program. If the file type is already known, it should just plug it in to the run command and run the file. This is not happening and I am not sure why exactly. If i look at it for a couple days I will prob figure it out, but would prefer if someone can see the problem and show me the way to fix it. Sorry, I should have been more specific as to the problem. If you run it you will see what I'm sayin, it just keeps recycling through the input program to run file type.
KnowledgeSponge Posted July 28, 2004 Author Posted July 28, 2004 (edited) Not that anyone is prob interested, as this is pretty much something i just wanted for myself, but here is the proper working code. I guess someone could use parts of it to open all file types, have seen a couple threads on that. If you took peices of this you could create a run script with expandable file type and programs used to launch db. $DEFAULT = ClipGet() $CHOSENFILE = InputBox("Location", "Please enter the remote file location", $DEFAULT) If @error = 1 Then Exit EndIf $SAVEAS = FileSaveDialog("Save to", @DesktopCommonDir, "All(*.*)", 16) If @error = 1 Then Exit EndIf URLDownloadToFile($CHOSENFILE, $SAVEAS) SoundPlay(@ScriptDir & "\completed.mp3") $OPENIT = MsgBox(4, "Download Complete!", "Open " & $SAVEAS & "?") If $OPENIT = 6 Then $CHARSTOREMOVE = StringInStr($SAVEAS, ".") $FILETYPEGET = StringTrimLeft($SAVEAS, $CHARSTOREMOVE) $CHECKKNOWN = IniRead(@ScriptDir & "\filetypes.ini", "Known File Types", $FILETYPEGET, "NULL") If $CHECKKNOWN = "NULL" Then $NEWTYPE = FileSaveDialog("Select the Program to Run", @DesktopCommonDir, "EXE Files (*.exe)", 1) If @error = 1 Then MsgBox(0, "No File Selected", "No File Selected. The program cannot continue.") Exit EndIf IniWrite(@ScriptDir & "\filetypes.ini", "Known File Types", $FILETYPEGET, $NEWTYPE) EndIf $EXELOC = IniRead(@ScriptDir & "\filetypes.ini", "Known File Types", $FILETYPEGET, "NULL") If $EXELOC = "NULL" Then MsgBox(0, "Error", "Error reading location. Exiting.") Else $LLOC = '"' & $EXELOC & '"' $PARAM = '"' & $SAVEAS & '"' Run($LLOC & " " & $PARAM) Exit EndIf EndIf Exit Edited July 29, 2004 by KnowledgeSponge
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