GEOSoft Posted December 13, 2003 Share Posted December 13, 2003 Are the following still valid in Ver 3? If not what are the new commands? IfMsgBox GoTo GoSub Return IfInString IfNotInString I used "Select" to replace a few IfInString but that was doing it the hard way because the entire string from the registry had to be checked instead of just 3 0r 4 numbers. It looks like the Help file still needs a lot of work. Reading through the posts here I am finding things that are not yet documented. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
CyberSlug Posted December 13, 2003 Share Posted December 13, 2003 (edited) AutoIt version 3 has a bunch of functions and a real IF statement:If $x = 1 ;equality testIf $x >= 1 AND $x <= 10 ;number between 1 and 10 inclusiveIf ($x = 1) OR ($x = 2) OR ($x = 3) ;a bunch of casesIf NOT (x = 5) ;inequalityIf x <> 5 ;logically equivalent to the previous oneAnd so onGoTo is not supported; there is a forum topic about thisGoSub/Return has been replaced with function declarations:Func functioname([byRef] $param1, [byRef] $param2)EndFunc; As for IfInStr, you can use the followingIf StringInStr( "string", "substring", [casesense] ) Then; code goes hereEndIfHOWEVER, this is *possibly* a bad coding style. StringInStr returns the index of the string (or returns zero if not found). AutoIt treats a nonzero value as TRUE and zero as FALSE, I believe. So it might be better to say:$myVariable = StringInStr( "string", "substring", [casesense] ) ThenIf $myVariable > 0 MsgBox(0,"","Substring was found...")Else MsgBox(0,"","String not found")EndIfIf Not StringInStr( "string", "substring", [casesense] ) Then; code goes hereEndIfMsgBox is a bit tricky$x = MsgBox(0,"Title","Text goes here")If $x = 0 Then; user clicked OK buttonEndIfSee the help file--under the respective sections--for details. Edited December 13, 2003 by CyberSlug 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...
GEOSoft Posted December 13, 2003 Author Share Posted December 13, 2003 Thanks CyberSlug. I have the whole script working now but it sure seems bulky. Having GoSub/Return was much, much better. That way if someone made an error in an input box I could return them to the beginning of that Sub so they could try again. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
CyberSlug Posted December 13, 2003 Share Posted December 13, 2003 Care to post your code? You can use While...WEnd and other loops to achieve this. 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...
Administrators Jon Posted December 13, 2003 Administrators Share Posted December 13, 2003 Thanks CyberSlug. I have the whole script working now but it sure seems bulky. Having GoSub/Return was much, much better. That way if someone made an error in an input box I could return them to the beginning of that Sub so they could try again.Trust me, once you have got the hang of While/Do/For/ExitLoop/ContinueLoop there are very few v3 scripts that will anything like as large/complicated as a v2 script. Especially when you look back on code that had Gotos everywhere. As for your input box, if you want to make sure a input matches your requirements and loop until it does so, something like this may help: $loop = 1 Do $input = InputBox("Input", "Enter your name") If $input <> "Jon" Then MsgBox(0, "", "Sorry, must enter 'Jon' to continue") Else $loop = 0 ; Will make the loop stop below EndIf Until $loop <> 1 Or: Do $input = InputBox("Input", "Enter your name") If $input <> "Jon" Then MsgBox(0, "", "Sorry, must 'Jon' to continue") EndIf Until $input = "Jon" And something to remember is that it's very hard to convert complex scripts from v2 to v3 because you need to think in a different way. Writing new scripts is a doddle once you are in the "zone" though (I won't be converting my old big scripts i'll continue to use 2.64 for those ) Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
GEOSoft Posted December 13, 2003 Author Share Posted December 13, 2003 Thanks again CS and Jon. It looks like I can work with those loops OK. The reasons I want this script converted are; A) I can have a default field in the input boxes. In the old script I had to disable one of them because it was downright disasterous if that reg key was left empty. The ability to Cancel from an input box. There are a lot of nice features in ver 3 but it's going to take some getting used to. I also have an idea of running it with Larry's GUI at some point, but that will wait untill I am more familiar with this version, or it may never get done. BTW another (simple) script calls for getting the free disk space as a percentage of the total drive space. I have that working but it returns with about 4 decimal places. Is there an easy way to round that up to one or two? and is there a simple loop to run that would return the available space on each drive without hardcoding the drive path? I never know how many partitions the user may have so it would have to start with C: and increment until it ran out of fixed disks and at the same time report the space for each fixed disk. The idea is that it starts up a defrag application that should never be run on a drive with less than 15% free space. If one drive is less than that, the drive has to be skipped. This one is not urgent since I still have a lot more to do on the app anyway. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
CyberSlug Posted December 13, 2003 Share Posted December 13, 2003 (edited) ; Yeah, this code could be better written--but is final revision, I hope $drive = 67;ASCII value of 'C' Do $freeSpace = PrettyPrint(DriveSpaceFree(Chr($drive) & ":\"), 2, 1) MsgBox(0,"Free space on " & Chr($drive) & ":\ is", $freeSpace & " Megabytes") $drive = $drive + 1 Until $freeSpace == 0 ; Parameters: number, digitsAfterDecmialPoint, whetherToPutCommas ; This truncates instead of rounding, but that's close enough :-) Func PrettyPrint($var, $precision, $commas) $dot = StringInStr($var, ".") $tmp = StringLeft($var, $dot + $precision) If $commas Then For $i = $dot-4 to 1 step -3 $tmp = StringLeft($tmp,$i) & "," & StringTrimLeft($tmp,$i) Next EndIf Return $tmp EndFunc Edited December 13, 2003 by CyberSlug 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...
GEOSoft Posted December 13, 2003 Author Share Posted December 13, 2003 Well it looks like a good starting point anyway. It also checks the CD drives when it should only be checking hard drives but I will work at it. Thanks a lot. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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