dcop Posted September 18, 2009 Share Posted September 18, 2009 When I try to execute the code below when compiled thru VBA (shell command) or theu a file:// url from brower I get.. Line -1: Error: Array variable subscript badly formatted It works fine thru Scite or with a doubleclick on the exe or theu the Start/Run. TIA, Dennis Here is what is in list.dlm: (following 2 lines) ORCL,FISV,BKC,MO,SYY,KR,RSH 8 include <Excel.au3> Dim $ini = 'list.dlm' $source = @WorkingDir & "\oracleFisv" FileDelete($source) $list = FileReadLine($ini, 1) $n = FileReadLine($ini, 2) Dim $symbol[$n] InetGet("http://finance.yahoo.com/q?s=" & $list & "&d=s", $source, 1) $txt = FileRead($source) $oExcel = _ExcelBookAttach("dlx.xls", "FileName") Dim $row = 3, $col = 16 For $i = 0 To $n - 1 $a = StringMid($txt,StringInStr($txt,"yfs_l10",0,$i) + 10, 15) $symbol[$i] = StringRegExpReplace($a,"[^0-9.]","") _ExcelWriteCell($oExcel, $symbol[$i], $row, $col) $row = $row + 1 Next Link to comment Share on other sites More sharing options...
Zedna Posted September 20, 2009 Share Posted September 20, 2009 (edited) Use absolute path in: Dim $ini = 'list.dlm' for example: Dim $ini = @ScriptDir & '\list.dlm' Edited September 20, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
dcop Posted September 24, 2009 Author Share Posted September 24, 2009 Thank you Zedna. Worked great! I dont understand why that caused the 'array' error tho. Dennis Link to comment Share on other sites More sharing options...
Zedna Posted September 24, 2009 Share Posted September 24, 2009 (edited) Thank you Zedna. Worked great! I dont understand why that caused the 'array' error tho. Dennis Dim $ini = 'list.dlm' $n = FileReadLine($ini, 2) Dim $symbol[$n] FileReadLine() doesn't find file (in working directory here) so $n is probably zero or empty string and then Dim $symbol[0] or Dim $symbol[""] is incorrect You can avoid such problems by using If @error then ... at places where you could expect problems here after FileReadLine(). Edited September 24, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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