cherdeg Posted November 6, 2008 Share Posted November 6, 2008 (edited) Hi,I use @ScriptDir in several of my scripts. And each time I have to work around it's inconsistent behaviour:Global $s_ScriptHome = @ScriptDir $s_ToolsShare = $s_ScriptHome & "\Tools" MsgBox("", "TEST", $s_ToolsShare)Started from a drive root, this returns e.g. "d:\\Tools". Started from a UNC-path or local subdirectory, it returns "\\servername\sharename\foldername\Tools" or "c:\folder\Tools" (please mind the number of backslashes). If @ScriptHome's behaviour was consistent, it would either always or never return the closing "\". But doing it on @Developer-Team: Please fix in next release!Thank you very much,Regards,Chris Edited November 6, 2008 by cherdeg Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 6, 2008 Share Posted November 6, 2008 Hi, I use @ScriptDir in several of my scripts. And each time I have to work around it's inconsistent behaviour: Global $s_ScriptHome = @ScriptDir $s_ToolsShare = $s_ScriptHome & "\Tools" MsgBox("", "TEST", $s_ToolsShare) Started from a drive root, this returns e.g. "d:\\Tools". Started from a UNC-path or local subdirectory, it returns "\\servername\sharename\foldername\Tools" or "c:\folder\Tools" (please mind the number of backslashes). If @ScriptHome's behaviour was consistent, it would either always or never return the closing "\". But doing it on @Developer-Team: Please fix in next release! Thank you very much, Regards, Chris Search the forum before you post, especially proposing bug reports. This has been discussed MANY times already. The behavior is consistent with other languages and is based on the logic that "D:" is not a directory, therefore "D:\" is more appropriate for @ScriptDir. It is even consistent with other operating systems that sensibly don't even use drive letters, like various Linux-based distros where pwd will return "/home/PsaltyDS" in home directory, but returns "/" for root. No bug. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Bert Posted November 6, 2008 Share Posted November 6, 2008 agreed. NO BUG The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
cherdeg Posted November 6, 2008 Author Share Posted November 6, 2008 Search the forum before you post, especially proposing bug reports. This has been discussed MANY times already.Yes, I know. Because I searched. But sadly the search delivered NO SINGLE satisfying result.The behavior is consistent with other languages and is based on the logic that "D:" is not a directory, therefore "D:\" is more appropriate for @ScriptDir. It is even consistent with other operating systems that sensibly don't even use drive letters, like various Linux-based distros where pwd will return "/home/PsaltyDS" in home directory, but returns "/" for root.No bug.Hey: I'm not using C, C++ or C#. Neither I'm using Java, Python or PHP, nor Pascal, Delphy or VB. I am using AutoIT! If something is appropriate or not should depend on its practical relevance and not on overcome principles. And last but not least I again use ... AutoIt, which implicates that I am using Windows as operating system and nothing else. So why care for facts on 'xes? If it's not a bug, it's by all means nothing less than a major annoyance. And sorry, but If something returns at one place a "\" and at another place not, is this a matter of inconsistency - and only by repeatedly telling users the opposite, your assertion won't get truer.But, if you don't want to ease the allover usage of AutoIt by changing @ScriptDir, why not create simply a macro @ScriptLoc or @ScriptHome? Doing that you guys could keep up your strange, inexplicable and crude logic and still make life easier for the people using AutoIt.Regards, Chris Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 6, 2008 Share Posted November 6, 2008 Yes, I know. Because I searched. But sadly the search delivered NO SINGLE satisfying result.Hey: I'm not using C, C++ or C#. Neither I'm using Java, Python or PHP, nor Pascal, Delphy or VB. I am using AutoIT! If something is appropriate or not should depend on its practical relevance and not on overcome principles. And last but not least I again use ... AutoIt, which implicates that I am using Windows as operating system and nothing else. So why care for facts on 'xes? If it's not a bug, it's by all means nothing less than a major annoyance. And sorry, but If something returns at one place a "\" and at another place not, is this a matter of inconsistency - and only by repeatedly telling users the opposite, your assertion won't get truer.But, if you don't want to ease the allover usage of AutoIt by changing @ScriptDir, why not create simply a macro @ScriptLoc or @ScriptHome? Doing that you guys could keep up your strange, inexplicable and crude logic and still make life easier for the people using AutoIt.Regards, ChrisYou're right! You should demand that Jon refund your AutoIt purchase price! And Microsoft should change the behavior of "CD" at the DOS prompt and the matching macros in all their languages, too! All seriousness aside, you could just write a _ScriptDir() function for yourself that sets up the string as you like it and always put _ScriptDir() in place of @ScriptDir. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
senthor Posted November 6, 2008 Share Posted November 6, 2008 Func _ScriptDir() If StringRight(@ScriptDir, 1) = "\" Then return SetError(0,0,StringTrimRight(@ScriptDir, 1)) Else return SetError(0,0,@ScriptDir) EndIf EndFunc Happy now? FileListToArray UDFMy tools Link to comment Share on other sites More sharing options...
cherdeg Posted November 6, 2008 Author Share Posted November 6, 2008 Just...go and get stuffed Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 6, 2008 Share Posted November 6, 2008 Just...go and get stuffed No thanks, I just had lunch... The code from senthor actually corrected a misunderstanding for me. I didn't think it would work because SetError() wouldn't return anything but an integer. I had forgotten that was fixed a long time ago and you could return anything with it now: ; Set @error test For $n = 1 To 4 $RET = _Test($n) $iErrSav = @error $iExtSav = @extended $sType = VarGetType($RET) ConsoleWrite("$RET = " & $RET & " Type = " & $sType & " @error = " & $iErrSav & " @extended = " & $iExtSav & @LF) Next Func _Test($i) Switch $i Case 1 ; integer Return SetError(1, 1, 1) Case 2 ; float Return SetError(2, 2, Sqrt(2)) Case 3 ; string Return SetError(3, 3, "Three") Case 4 ; array Return SetError(4, 4, StringSplit("1,2,3,4", ",")) EndSwitch EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
senthor Posted November 6, 2008 Share Posted November 6, 2008 (edited) Even Most Venerable Penguins can learn something more Edited November 6, 2008 by senthor FileListToArray UDFMy tools Link to comment Share on other sites More sharing options...
spudw2k Posted November 6, 2008 Share Posted November 6, 2008 (edited) Just because someone offered a reasonable and simple method to correct your issue, it doesn't mean you should take offense. C:\\tools should work anyways as pointed out by Hubertus. Edited November 6, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
cherdeg Posted November 7, 2008 Author Share Posted November 7, 2008 Hey guys, very nice of you to inform me that "C:\\Tools" is working...sometimes. Not that I wouldn't know myself...but I suppose none of you has to care about systems running Windows NT or Windows 2000, right? But alas I (have to) do. Just test this on W2K, you hardly won't find any NT systems still floatin' 'round anywhere... Global $s_ToolsShare = @ScriptDir & "\Tools" $i_RVal = FileExists($s_ToolsShare & "\" & $s_RegFile) If $i_RVal <> 1 Then MsgBox(16, "TEST", "Error! The registry-file " & $s_RegFile & " was not found!", "") Exit EndIf The code simply won't do the magic on any OS before XP and with a value like "D:\\Tools" for $s_ToolsShare; $i_RVal will never be "1" in such a situation. This was the reason that originally brought me here... Regards, Chris Link to comment Share on other sites More sharing options...
spudw2k Posted November 7, 2008 Share Posted November 7, 2008 The code simply won't do the magic on any OS before XP and with a value like "D:\\Tools" for $s_ToolsShare; $i_RVal will never be "1" in such a situation. This was the reason that originally brought me here... Regards, ChrisDoes Senthor's solution not work for you? Func _ScriptDir() If StringRight(@ScriptDir, 1) = "\" Then return SetError(0,0,StringTrimRight(@ScriptDir, 1)) Else return SetError(0,0,@ScriptDir) EndIf EndFunc Happy now? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
cherdeg Posted November 10, 2008 Author Share Posted November 10, 2008 Does Senthor's solution not work for you?I'm sure it would - but I'm not in search for a solution: In my tools I use a stringreplace(). All I want is to tell you guys, that @ScriptDir is not perfect and that, no matter which further criterions you enumerate, this fact won't change. Link to comment Share on other sites More sharing options...
BrettF Posted November 10, 2008 Share Posted November 10, 2008 It's perfect, you obviously don't think it is, but it is- in other words it does what is intended. It will not be changed and you have a solution, so why are you still here complaining? If you'd taken 30seconds to search for this, you would have found that it has been discussed before, and deemed as a NOBUG. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
cherdeg Posted November 10, 2008 Author Share Posted November 10, 2008 @Brett:...no matter which further criterions you enumerate, this fact won't change. Link to comment Share on other sites More sharing options...
spudw2k Posted November 10, 2008 Share Posted November 10, 2008 I'm sure it would - but I'm not in search for a solution: In my tools I use a stringreplace(). All I want is to tell you guys, that @ScriptDir is not perfect and that, no matter which further criterions you enumerate, this fact won't change.Well you know, you could always find another language to play with if this one doesn't work for you; one that offers "perfect" (by your definition) pre-made macros and methods. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
cherdeg Posted November 12, 2008 Author Share Posted November 12, 2008 But using root directory as script repositoty is also not perfect. - Righty-Rrrright. But if you have to run a tool by autorun.inf from a CD... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 12, 2008 Moderators Share Posted November 12, 2008 @cherdeg ... It is good that you have found that you need a solution (My personal preference is RegExp one), rather than having systems bouncing your script with unwanted errors (or maybe that's how you found the errors to begin with?). Rather than arguing with everyone, I'd suggest you open a ticket (as a feature request) to the Devs on your concern and or wishful solution. The worse case scenario there is you get told yourself to get stuffed. Either way, you have your own solution to the issue, and can avoid a lack of understanding. 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...
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