Brady Posted September 1, 2006 Share Posted September 1, 2006 I'm creating a script to run install programs in silent mode, the idea being that someone will run the program and it will install a group of programs all at once. It will also display a progress bar so that the user knows that something is happening and when it is done. Problem is that I'm getting an error saying: "Variable must be of type "Object" after it gets done with all of the files and so it never leaves the loop to display the completed progress bar and exit. The line is occuring on line 53, which is the line just following ; run install and increase progress baroÝ÷ Ù«¢+ØÌ(%Q¡¥ÌÁɽɴݥ±°ÉÕ¸±°¥¹Íѱ°Áɽɵ̥¸Ñ¡Ìäí¥¹Íѱ°Ìäì¥ÉѽÉ䥸ͥ±¹Ðµ½¸($(% ÕÉɹѱäݽÉ̽ÈÍÑÕÀ¥±ÌÉÑÝ¥Ñ è($$´%¹¹¼MÑÕÀ($$´9Õ±±Í½Ð%¹Íѱ±È($$´¡½ÍÐ%¹Íѱ±È($$´5¥É½Í½Ð%¹Íѱ±È¡µÍ¤±µÍÀ¤($$´Q¥¸%¹Íѱ±È($$´]¥¹i¥ÀM±áÑÉÑ¥¹%¹Íѱ°((¥¹±Õ±Ðí¥±¹ÔÌÐì(¥¹±Õ±ÐíÉÉä¹ÔÌÐì()¥´ÀÌØíÍÝ¥Ñ °ÀÌØí¹Õµ}¥±ÌôÀ°ÀÌØíÁɽÉÍÌôÀ()AɽÉÍÍ=¸ ÅÕ½Ðí%¹Íѱ±¥¹M½ÑÝɸ¸¸ÅÕ½Ðì°ÅÕ½Ðí%¹Íѱ±¥¹Í½ÑÝÉ°Á±ÍÝ¥ÐÅÕ½Ðì°ÌäìÌäì°àà¤((ìб¥Íн¥Éѽɥ̥¸Ñ¡½±È(ÀÌØí¥ÉѽɥÌô}¥±1¥ÍÑQ½ÉÉä¡MÉ¥ÁѥȰÌäì¨Ìäì°È¤)}ÉÉå±Ñ ÀÌØí¥Éѽɥ̰ÌäìÀÌäì¤((ì ½Õ¹Ð¹ÕµÈ½¥±Ì½ÈÁɽÉÍÌÈ)½ÈÀÌØí¥È¥¸ÀÌØí¥ÉѽɥÌ($ÀÌØí¥±}ÉÉäô}¥±1¥ÍÑQ½ÉÉä¡MÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥È°ÅÕ½Ð쨹áÅÕ½Ðì¤(%}ÉÉå±Ñ ÀÌØí¥±}ÉÉä°ÌäìÀÌäì¤(%}ÉÉå¥ÍÁ±ä ÀÌØí¥±}ÉÉä°ÌäíÔÌäì¤($ÀÌØí¹Õµ}¥±Ì¬ô U ½Õ¹ ÀÌØí¥±}ÉÉ䤤$)9áÐ()5Í ½à Ä°ÅÕ½Ðí¹ÕµÈ½¥±ÌÅÕ½Ðì°ÀÌØí¹Õµ}¥±Ì¤()½ÈÀÌØí¥È¥¸ÀÌØí¥ÉѽɥÌ((ìMÐÍÝ¥Ñ Í½¸Ý¡¥ ¥ÉѽÉäÍÉ¥ÁÐ¥ÌÕÉɹѱ䥸(%¥ÀÌØí¥ÈôôÌäí¥¹¹¼ÌäìQ¡¸($$ÀÌØíÍÝ¥Ñ ôÅÕ½Ðì½ÙÉåÍ¥±¹ÐÅÕ½Ðì(%¹%($$(%¥ÀÌØí¥ÈôôÌäí¹Õ±±Í½ÐÌäìQ¡¸($$ÀÌØíÍÝ¥Ñ ôÅÕ½Ðì½ÌÅÕ½Ðì(%¹%($(%¥ÀÌØí¥ÈôôÌäí¡½ÍÐÌäìQ¡¸($$ÀÌØíÍÝ¥Ñ ôÅÕ½ÐìµÌÅÕ½Ðì(%¹%($($ìÐ¥±Ì¥¸ÕÉɹХÉѽÉä($ÀÌØí¥±}ÉÉäô}¥±1¥ÍÑQ½ÉÉä¡MÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥È°ÅÕ½Ð쨹áÅÕ½Ðì¤(%}ÉÉå±Ñ ÀÌØí¥±}ÉÉä°À¤($($ìÉÕ¸¥¹Íѱ°¹¥¹ÉÍÁɽÉÍÌÈ(%½ÈÀÌØí¥±¥¸ÀÌØí¥±}ÉÉä($$íIÕ¹]¥Ð¡MÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥ÈµÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥±µÀìÅÕ½ÐìÅÕ½ÐìµÀìÀÌØíÍÝ¥Ñ ±MÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥È¤($%5Í ½à Ä°ÌäíÑÍÐÌäì°MÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥ÈµÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥±µÀìÅÕ½ÐìÅÕ½ÐìµÀìÀÌØíÍÝ¥Ñ ¤($$ÀÌØíÁɽÉÍÌôÀÌØíÁɽÉÍ̬Ä($%AɽÉÍÍMÐ ÀÌØíÁɽÉÍ̼ÀÌØí¹Õµ}¥±Ì¨ÄÀÀ¤(%9áÐ)9áÐ)AɽÉÍÍMÐ ÄÀÀ°ÅÕ½Ðí½¹ÅÕ½Ðì°ÅÕ½Ðí ½µÁ±ÑÅÕ½Ðì¤)AɽÉÍÍ= Any ideas? Thanks, Brady Link to comment Share on other sites More sharing options...
Helge Posted September 1, 2006 Share Posted September 1, 2006 (edited) You need to do some reading about For/Next-loops. Test this :For $i = 1 To $file_array[0] ;RunWait(@ScriptDir & "\" & $dir & "\" & $file & " " & $switch,@ScriptDir & "\" & $dir) MsgBox(1, 'test', @ScriptDir & "\" & $dir & "\" & $file_array[$i] & " " & $switch) $progress = $progress + 1 ProgressSet($progress / $num_files * 100) Next Edit : typo Edited September 1, 2006 by Helge Link to comment Share on other sites More sharing options...
Brady Posted September 1, 2006 Author Share Posted September 1, 2006 You need to do some reading about For/Next-loops.Can you reccomend somewhere to do this reading? I've read what is in the help file, and I'm still unsure why my code doesn't work. Most confusing is that the code having problems is exactly like a loop earlier in the code that works just fine. Test this :For $i = 1 To $file_array[0] ;RunWait(@ScriptDir & "\" & $dir & "\" & $file & " " & $switch,@ScriptDir & "\" & $dir) MsgBox(1, 'test', @ScriptDir & "\" & $dir & "\" & $file_array[$i] & " " & $switch) $progress = $progress + 1 ProgressSet($progress / $num_files * 100) NextWhen I try that code I get the following error message: Subscript used with non-Array variable.Thanks, Brady Link to comment Share on other sites More sharing options...
Brady Posted September 1, 2006 Author Share Posted September 1, 2006 I was able to get it working by using:For $i = 1 To UBound($file_array) - 1 I'm still not sure why neither the original or the solution posted by Helge worked properly. If anyone has any ideas I would love to hear them. I'm pretty new to AutoIt so I know I've got lots to learn still. Thanks for your help Helge. Brady Link to comment Share on other sites More sharing options...
Helge Posted September 1, 2006 Share Posted September 1, 2006 Yes, I was thinking about the helpfile. Just read the docs and study the example. That error-message means that _FileListToArray has failed, so you should add a error-check after using that function. If @error doesn't equal 0 then you've either done something wrong or there aren't any files in the directory. Link to comment Share on other sites More sharing options...
Brady Posted September 1, 2006 Author Share Posted September 1, 2006 Yes, I was thinking about the helpfile. Just read the docs and study the example.That error-message means that _FileListToArray has failed, so you should add aerror-check after using that function. If @error doesn't equal 0 then you've eitherdone something wrong or there aren't any files in the directory.You nailed it on the head. One of the directories that it is parsing doesn't have any files in it yet, so that's what was causing the error.I've added the error check and it's working exactly as it should.Thanks again for your help Helge!Brady 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