emmanuel Posted May 13, 2004 Share Posted May 13, 2004 Larry, I bet you could write this in your sleep... to properly do the dircreate based on the $sztarget var, I need to strip the string of the filename at the end... how? I can almost see the answer in my head... but the examples in the helpfile are all so simple, they don't seem to apply... Func getfile($szFile, $szTarget) If Not FileExists($szDownloadDir) Then DirCreate($szDownloadDir) EndIf If Not FileExists($szTarget) Then DirCreate($szTarget) EndIf TrayTip("Downloading...", $szFile, 10) $IntErrCheck = URLDownloadToFile($szBaseURL & $szfile,$szDownloadDir & "\" & $szTarget) if $IntErrCheck = 0 then $IntErrResponse = MsgBox(2,"Error Downloading " & $szFile, "There was an error downloading " & $szFile) If $IntErrResponse = 3 then Exit;abort ElseIf $IntErrResponse = 4 Then getfile($szFile,$szTarget) ElseIf $IntErrResponse = 5 Then EndIf EndIf EndFunc ;==>getfile "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Valik Posted May 13, 2004 Share Posted May 13, 2004 (edited) Use the _SplitPath() function I've posted. It seperates a path into the 4 logical components:DriveDirectoryFile nameExtensionIt's being used in the FileInstall helper script so you can get it from there. You can just recombine the Drive & Directory after splitting the path.Edit: See here for the full source to the function and an example of usage. Edited May 13, 2004 by Valik Link to comment Share on other sites More sharing options...
emmanuel Posted May 13, 2004 Author Share Posted May 13, 2004 thank you very much for pointing to the full version, needed the explanations... will this work on something without a drive? like a vlaue of "new\Aut2exe\AutoItSC.bin" "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted May 13, 2004 Author Share Posted May 13, 2004 what did I do wrong? --------------------------- AutoIt Error --------------------------- Line 37 (File "C:\Documents and Settings\&eplesh\My Documents\script scraps\update autoit\get and install latest autoit.au3"): _SplitPath($szTarget, ByRef $szTargetDrive, ByRef $szTargetDir, ByRef $szTargetFName, ByRef $szTargetExt) _SplitPath($szTarget, ^ ERROR Error: Expected a variable in user function call. --------------------------- OK --------------------------- I removed the ByRefs from that, got this: --------------------------- AutoIt Error --------------------------- Line 37 (File "C:\Documents and Settings\&eplesh\My Documents\script scraps\update autoit\get and install latest autoit.au3"): _SplitPath($szTarget, $szTargetDrive, $szTargetDir, $szTargetFName, $szTargetExt) _SplitPath($szTarget, ^ ERROR Error: Variable used without being declared. --------------------------- OK --------------------------- "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted May 13, 2004 Author Share Posted May 13, 2004 Dim $szTargetDrive, $szTargetDir, $szTargetFName, $szTargetExt fixed that... "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted May 13, 2004 Author Share Posted May 13, 2004 though I am apparently not getting back either $szTargetDir or $szTarget[2] with the folder info. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Valik Posted May 14, 2004 Share Posted May 14, 2004 It works fine for me. As far as I know, 1 or more parts can be missing and it will report what is there. I tested it with your path you showed and it worked fine. $path = "new\Aut2exe\AutoItSC.bin" Local $d, $dr, $fn, $ext _SplitPath($path, $d, $dr, $fn, $ext) MsgBox(4096, "", $d & @CRLF & $dr & @CRLF & $fn & @CRLF & $ext) Link to comment Share on other sites More sharing options...
CyberSlug Posted May 14, 2004 Share Posted May 14, 2004 The current "unstable" AutoIt build has improved StringInStr so that it has an "occurrence" parameter. StringTrimLeft($filename, StringInStr($filename,"\",0,-1)Or for a slightly better version:MsgBox(4096,"Example", stripPath("C:\Windows\System32\calc.exe")) Func stripPath($filename) $filename = StringReplace($filename, "/", "\");in case Unix-style path Local $pos = StringInStr($filename,"\",0,-1) Return StringTrimLeft($filename, $pos) EndFuncCome on, you know you want the "unstable" download Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
emmanuel Posted May 14, 2004 Author Share Posted May 14, 2004 yeah, you know what's funny? I'm writing this script to automatically download the unstable version and install it. So, funny enough, looks like I will have to install the unstable version to script the install of the unstable version. I believe that's called irony. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted May 14, 2004 Author Share Posted May 14, 2004 (edited) I think the term is ugh. but seriously. What's people's feelings on pasting whole scripts up here when asking for help? Is it rude? Is it asking too much? Edited May 14, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Nutster Posted May 15, 2004 Share Posted May 15, 2004 What's people's feelings on pasting whole scripts up here when asking for help? Is it rude? Is it asking too much?It depends on size. Try to keep it small. Try to isolate the one section that is giving you the most grief. If that doesn't help enough, you may get asked to post more of the script. If you want to post a working script (Way to go! ), put it in Scripts and Scraps. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
emmanuel Posted May 17, 2004 Author Share Posted May 17, 2004 It depends on size. Try to keep it small. Try to isolate the one section that is giving you the most grief. If that doesn't help enough, you may get asked to post more of the script. If you want to post a working script (Way to go! ), put it in Scripts and Scraps. thanks, that's basically what I've been aiming at... and now that I've started to grok functions it's easier to just post what the problem is instead of the whole script... "I'm not even supposed to be here today!" -Dante (Hicks) 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