ACalcutt Posted August 12, 2005 Share Posted August 12, 2005 (edited) I was wondering if anyone knows a simple what to get rid of the trailing "\" in @working dir when it is in the root of the drive....If i use @workingdir in the root of the drive (like F:, no folder) its value would come up as "F:\"...but if its in a dir (like F:\dir) it would come up as "F:\dir"is their a way to either make the traing backslash on the drive to go away or to always put it?right now i am doing thisIf IniRead($settings, "Script_Settings", "Working_Dir", "") = "" Then IniWrite($settings, "Script_Settings", "Working_Dir", @WorkingDir) EndIfDim $workingdir = IniRead($settings, "Script_Settings", "Working_DIR", "")If FileExists($workingdir & @ScriptName) = 0 Then Dim $workingdir = IniRead($settings, "Script_Settings", "Working_DIR", "") & "\"Endifusually my program is on a cd root...but when i work on it its not in a root folder...and untill i did the above change...i had to add the trailing backslash when i tested it on my computer Edited August 12, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
w0uter Posted August 12, 2005 Share Posted August 12, 2005 maby you should have posted in the bugreport section My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
ACalcutt Posted August 12, 2005 Author Share Posted August 12, 2005 (edited) maby you should have posted in the bugreport section <{POST_SNAPBACK}>well it may be a bug....but i did know if their may have been an option...and i was hoping someone had a solution...i'll post it in the bug section 2 Edited August 12, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
hgeras Posted August 12, 2005 Share Posted August 12, 2005 If you put this in the start of the program then you should be fine.... $Working_dir=@WorkingDir If StringLen($Working_Dir)=3 Then ;<--To make sure you are on a root dir $Working_Dir=StringTrimRight($Working_Dir,1) EndIf Then you have to always use $Working_Dir instead of @WorkingDir.... C ya Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
w0uter Posted August 12, 2005 Share Posted August 12, 2005 what if ya use SetWorkingDir My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
hgeras Posted August 12, 2005 Share Posted August 12, 2005 Is there such a function? Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
ACalcutt Posted August 13, 2005 Author Share Posted August 13, 2005 (edited) If you put this in the start of the program then you should be fine....$Working_dir=@WorkingDir If StringLen($Working_Dir)=3 Then ;<--To make sure you are on a root dir $Working_Dir=StringTrimRight($Working_Dir,1) EndIfThen you have to always use $Working_Dir instead of @WorkingDir....C ya<{POST_SNAPBACK}>I like this solution...i am already using $workingdir as the variable with my current solution....and also...i havent even looked at the string coding....because of this i will have to check it outBut i think i will use your suggestionI am changing it a little because the $workingdir variable is used in my script to reference were the install files are....but i also want this a changeable variable...so the dir can be specified in the ini...so basically i end up with the same about of code....but this is definatly a better way to do itIf IniRead($settings, "Script_Settings", "Working_Dir", "") = "" Then IniWrite($settings, "Script_Settings", "Working_Dir", @WorkingDir) EndIf$workingdir= IniRead($settings, "Script_Settings", "Working_DIR", "")If StringLen($workingdir)=3 Then $workingdir=StringTrimRight($workingdir,1)EndIfDim $workingdir = $workingdir & "\"what if ya use SetWorkingDir <{POST_SNAPBACK}>I was under the impression marcos wern't changable Edited August 13, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted August 13, 2005 Author Share Posted August 13, 2005 (edited) what about this$workingdir=@WorkingDirIf StringLen($workingdir)<>3 Then   $workingdir=$workingdir & "\"EndIfor in my case.... if this works i can have it like thisIf IniRead($settings, "Script_Settings", "Working_Dir", "") = "" Then  IniWrite($settings, "Script_Settings", "Working_Dir", @WorkingDir) EndIfDim $workingdir = IniRead($settings, "Script_Settings", "Working_Dir", "")If StringLen($workingdir)<>3 Then  $workingdir = $workingdir & "\"EndIf Edited August 13, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
ACalcutt Posted August 13, 2005 Author Share Posted August 13, 2005 (edited) hmm..in the post i made in bugreports i got thisIf StringRight($path, 1) <> "\" Then $path = $path & "\"either way...my problem is solved..thanks for the help Edited August 13, 2005 by ACalcutt Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
blindwig Posted August 13, 2005 Share Posted August 13, 2005 Just FYI, a path such as "C:\" does NOT have a trailing back slash. That backslash IS the path, because for example "C:WINDOWS" and "C:\WINDOWS" can be 2 completely different folders. A path such as "C:\WINDOWS\" has a trailing backslash. It is not a bug to return "C:\" as a path - if you were to return "C:" as a path, that WOULD be a bug, since "C:" isn't a path, it's a drive. I assume you want to use a path where you know weather or not it has a backslash at the end so that you can add a file and/or relative path to it? I have a function to do this, you might be interested in: expandcollapse popup;=============================================================================== ; ; Function Name: _FileJoinPath ; Description: Takes "C:\Path" and "FileName.Ext" and returns "C:\Path\FileName.Ext" ; Parameter(s): ; Requirement(s): _FileParsePath ; Return Value(s): string ; Author(s): Mike Ratzlaff <mike@ratzlaff.org> ; ;=============================================================================== ; Func _FileJoinPath($FileName1, $FileName2) Dim $PP1 = _FileParsePath($FileName1) Dim $PP2 = _FileParsePath($FileName2) If $PP2[0] <> '' Then Return $FileName2 If StringLeft($PP2[1], 1) = '\' Then Return $PP1[0] & $PP2[1] & $PP2[2] & $PP2[3] If StringRight($FileName1, 1) <> '\' Then Return $FileName1 & '\' & $FileName2 Else Return $FileName1 & $FileName2 EndIf EndFunc ;==>_FileJoinPath ;=============================================================================== ; ; Function Name: _FileParsePath ; Description: Takes a full path such as "C:\Path\File.Ext" and returns an array such as "C:","\Path\","File",".Ext" ; Parameter(s): ; Requirement(s): ; Return Value(s): A 4-element Array. See Description ; Author(s): Mike Ratzlaff <mike@ratzlaff.org> ; ;=============================================================================== ; Func _FileParsePath($FileName) Dim $Return[4];Drive, Path, Name, Extension Dim $Len If StringMid($FileName, 2, 1) = ":" Then $Return[0] = StringLeft($FileName, 2) $FileName = StringRight($FileName, StringLen($FileName) - 2) Else $Return[0] = '' EndIf $Len = StringInStr($FileName, "\", 0, -1) $Return[1] = StringLeft($FileName, $Len) $FileName = StringRight($FileName, StringLen($FileName) - $Len) $Len = StringInStr($FileName, ".", 0, -1) $Return[2] = StringLeft($FileName, $Len - 1) $FileName = StringRight($FileName, StringLen($FileName) - $Len + 1) $Return[3] = $FileName Return $Return EndFunc ;==>_FileParsePath My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions 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