Jump to content

SlimJim

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by SlimJim

  1. I have no experience with arrays and am trying to understand what you are doing for my own benefit as well, so I am making heavy use of the help file. First of all it seems to me that the line _arraySort($MSINFOArray) messes up the effect of the previous line _ArrayReverse($MSINFOArray) and in fact if you are sorting the array you may as well sort the initial array as the result should be the same. I think you may need somehow extract the first 25 lines from the reversed array into a new array, sort that and then try sorting out which lines contain "exe" Secondly in your _ArrayBinarySearch line Don't you need to specify a starting index. Your loop seems to be simply doing the same thing each time. The result of _ArrayBinarySearch is a key number specifying which element of the array contains the "exe" so in order to write that element to a file you need to specify which array element you are writing. $MSINFOArray[_arraybinarySearch($MSINFOArray, "exe")]
  2. It does "sound" logical, but it is not logically sound - sorry. Let me give a proper example as to why these two expressions will give a different result. In the first case to get a true result you have to have key pressed = "26" and then if that is true you need one of $a,$b,$c to be <> 0 together with both $d <> 0 and $e <> 0. In the second case there is a possibility of a true when the key pressed is not 26 For example if $b <> 0, $d <> 0, $e <> 0 then you get a true. This is a direct result of left to right calculating and it seems that if you are going to use a mixture of and's and or' in an expression it is always safer to put brackets in to ensure that you get the result you want.
  3. In the second case if the key pressed is "26" and $a = 0 then testing stops because we have a false. In the second case if the key pressed is "26" and $a = 0 testing continues. The reason is because and and or have the same precedence so testing proceeds from left to right until a conclusion. I think you can make these these the same by adding brackets -- And ($a <> 0 .... $e <> 0)
  4. So I need an extra line to check whether or not there is a "." in the $fullfilename and if not set $ext = "". Thank you for pointing that out.
  5. A somewhat delayed answer to this as the post about _PathSplit answers the question. However, for my own benefit I followed through my suggestion and have used your pathname as an example. As I said earlier I am essentially a beginner when it comes to AutoIt so I'm sure this can be improved. $filepath="\\server\sharename\path1\path2.ext\yyyymmdd.hhmm.log" ; BACKWARD OR FORWARD SLASHES? If StringInStr($filepath,"\") > 0 then $d = "\" elseif StringInStr($filepath,"/") > 0 then $d = "/" else $d="" endif ;FIRST SPLIT THE FILE PATH INTO FOLDERS AND THE FULL FILENAME $tree = Stringsplit($filepath,"/\",0) $fullfilename = $tree[$tree[0]] $namesplit = StringSplit($fullfilename,".",0) $ext = $namesplit[$namesplit[0]] $filename = StringLeft($fullfilename,StringLen($fullfilename) - StringLen($ext) - 1) ;NOW RECONSTRUCT $FILEPATH FROM THE $TREE ARRAY $FILENAME AND $EXT $makefilepath = "" For $i = 1 to $tree[0]-1 If $tree[$i] = "" then $makefilepath = $makefilepath & $d elseif $tree[$i] <> "" then $makefilepath = $makefilepath & $tree[$i] & $d endif next MsgBox(1,"Filepath",$makefilepath & $filename & "." & $ext)
  6. I'm neither a veteran nor an expert and read these forums in the hope of learning something. I have tried the function above (copy and paste) and get an unknown function error for _PathSplit. I have checked my version of file.au3and that does not mention _PathSplit. Can somebody tell me what the problem is please?
  7. I'm becoming a big fan of StringSplit. Try the following. The first line splits up the file path into an array of drive, foldernames,filename,extension and then the last two lines pick out the extension and the filename. $parts = StringSplit($file,"\.",0) $ext = $parts[$parts[0]] $filename = $parts[$parts[0] - 1]
  8. I took a different approach to this making the assumption that the words "hit for" and damage!" surround the numbers you are trying to find. If that is not the case then simply ignore this effort $parse1=StringSplit ($logline,"hit for",1) $parse2=StringSplit($parse1[2],"damage!",1) MsgBox(1,"points",$parse2[1])
  9. You're right, but it takes me back (retired math lecturer). This problem is one of the first proofs for which we used Mathematical Induction (which is the backbone of recursion) but I also remember doing this at secondary school before I came across Mathematical Induction and the method is neat, simple when you see it, but not something you would necessarily think of immediately. Let S = 1 + 2 + .... + N turn the order of the terms round, then S = N + (N-1) + ... + 1 add these two sums up term-by-term 2S = (N + 1) + (N -1 + 2) + .... + (1 + N) = N * (N + 1) all the brackets are equal to N + 1 and there are N of them, so the right hand side adds up to N * (N + 1). Divide both sides by 2 S = N * (N + 1) / 2
  10. Although you may have to use Mathematical Induction to prove this is the answer it it is not necessary to use recursion to calculate 1 + 2 + ... + N. The answer is N * (N + 1 ) / 2. The solution to the problem x*1 + x * 2 + ... + x * y y a positive integer, is x * y * (y + 1) / 2.
  11. I believe you need to use Opt("ExpandVarStrings",1) which allows you to use variables inside strings. I have not used this myself but it is mentioned in the help file with the example of a string "The value of var1 is $var1$"
  12. We learn more each day. I had not come across those.
  13. I am not an AutoIt expert but I think put a loop round the code you want repeated, with no exit condition is one way. For example: $j = 1 Do ;code you want to repeat including the pause until $j = 0
  14. Use cyanidemonkey's script but with the $gDrive & ":\Documents and Settings\All Users part replaced by %UserProfile%. You need the line Opt("ExpandEnvStrings",1) to ensure that the %UserProfile% environment string is expanded to a path which can be used. (apologies for the full stop instead of a comma)
  15. The following little script shows you the current user's profile address. Opt("ExpandEnvStrings",1) MsgBox(0."User Path","The current user's profile is at %UserProfile%",0)
  16. You could put the script into your startup folder in the start menu
  17. You could try using the text parameter, if there is a piece of text in the window which identifies the window you are looking for.
  18. Following BigDod's suggestion start your script with Opt("WinTitleMatchMode", 2) and then you can use "License", "Installation", "Start" and "Completed" to find the appropriate Window Titles
×
×
  • Create New...